Hmm ok, I will trust you, I investigated with iteration, Run it for to have your own conclusion, a_index << 0 is the winner and I guess it is because of a pure integer return, V2 run 10% better on my computer but i+=1 is two time slower. Also I imagine that a_index have a cache system. It will not be a waste time to work on built-in variable but it just my opinion, and as you said maybe good to have an object (equal performance ?). If someone want to try with real algo case...
Code: Select all
;SetBatchLines -1
msgbox start
t0 := a_tickcount
loop 2000000
{
var := a_index
}
t1 := a_tickcount-t0
t0 := a_tickcount
loop 2000000
{
var := a_index+a_index-a_index
}
t2 := a_tickcount-t0
t0 := a_tickcount
loop 2000000
{
var := a_index << 0
}
t3 := a_tickcount-t0
t0 := a_tickcount
i := 0
loop 2000000
{
i++
var := i
}
t4 := a_tickcount-t0
t0 := a_tickcount
i := 0
loop 2000000
{
i++
var := i+i-i
}
t5 := a_tickcount-t0
t0 := a_tickcount
i := 0
loop 2000000
{
i += 1
var := i
}
t6 := a_tickcount-t0
msgbox % t1 " ms : a_index`n" t2 " ms : a_index+a_index-a_index`n" t3 " ms : a_index << 0`n" t4 " ms : i (i++)`n" t5 " ms : i+i-i (i++)`n" t6 " ms : i i+=1"
However we can't have a fast trick here, and V2 is 10% slower
Code: Select all
;SetBatchLines -1
msgbox start
t0 := a_tickcount
loop 200000
{
var%a_index% := true
}
t1 := a_tickcount-t0
t0 := a_tickcount
i := 0
loop 200000
{
i++
var%i% := true
}
t2 := a_tickcount-t0
msgbox % t1 "`n" t2
return
For my noob eyes, when a_index is alone it doesn't return an integer