This is confusing.
I tried this code:
LOCAL start=0
LOCAL stop=200000
LOCAL stepping=0.005
LOCAL time0#, value#, s$
FOR trials = 0 TO 2
value = 0
time0=GETTIMERALL()
FOR i=start TO stop STEP stepping
value=value+1
NEXT
time0=GETTIMERALL()-time0
STDOUT time0+" ms\n"
NEXT
STDOUT "\n\n"
FOR trials = 0 TO 2
value = 0
time0=GETTIMERALL()
FOR i=start TO stop STEP stepping
value=value+1
NEXT
time0=GETTIMERALL()-time0
s$ = value
STDOUT time0+" ms\n"
NEXT
KEYWAIT
ENDThis gives me around 100ms for the pure loop, and 140ms for the loop which has "s$ = value" afterwards...
However, running this code:
LOCAL start=0
LOCAL stop=200000
LOCAL stepping=0.005
LOCAL time0#, value#, s$
value = 0
time0=GETTIMERALL()
FOR i=start TO stop STEP stepping
value=value+1
NEXT
time0=GETTIMERALL()-time0
STDOUT time0+" ms\n"
STDOUT "\n\n"
value = 0
time0=GETTIMERALL()
FOR i=start TO stop STEP stepping
value=value+1
NEXT
time0=GETTIMERALL()-time0
s$ = value
STDOUT time0+" ms\n"
KEYWAIT
END(The same code just w/o the for loops), I get 115ms and 140ms....
Using kakonet's original code (i.e. using 'value=1' instead of 'value=value+1'), with both snippets left in as above, I get the same times (115ms, 140ms).
Running either snippet on their own I get these times...
Using 'value = SIN(1)' instead, I get something like 4495ms for the one without the string, and 4505ms for the one with the string assignment afterwards.
I have tried things like adding a DELAY at the start and rearranging things, but get the same results.
Go figure

This seems like it has to do with optimisation, although I don't understand why things would turn out differently within for loops, or with a conversion to a string afterwards....