Mark,
when timing is so little, measuring it in multi threading environment (like Windows) can give very different results. I'm sure in your PC there are at least other 20/30 (if not more) process running at the same time. Everyone of those other process can do something (we do not know details) and when they do something they consume CPU cycles delaying other process (even if for few milli or micro seconds). The ideal situation would be to have just one process running (like old DOS) but now day this is not possible in standard PC. So to have credible results, it would be better to have tests that last at least few seconds instead of few milliseconds.
That said, back to the question: why INCR <variable> is faster than <variable> = <variable> + 1
thinBasic is an interpreted language so even few interpreting steps can make a lot of difference.
When you use INCR ... thinBasic just needs to make 2 steps: INCR followed by a variable. After that thinBasic has all the info to perform the operation.
When you use <variable> = <variable> + 1 thinBasic has to make a lot of parsing steps. Just to summarize a few info: first it identify a variable, than it assume it is an assignment so it will parse for equal sign, than it will start a recursive descendant parsing for a numeric expression, that it will assign the result to the assign variable ...
As you can see the two methods perform completely different.
To add 1 (or other values) to a variable, thinBasic also has <variable> += 1
Ciao
Eros
Bookmarks