Arrays in Rev (long)
Troy Rollins
troy at rpsystems.net
Tue Jul 13 00:08:55 EDT 2004
On Jul 12, 2004, at 11:41 PM, Richard Gaskin wrote:
> Yes, it takes almost six times longer to access a property than it
> does to access a local var. Run the benchmarking script below; on my
> modest single-processor G4 it gets:
>
> Props: 62 ms
> Vars: 12 ms
Hmm. Very interesting, my "modest" 1gHz G4 shows the same results for
vars exactly, but props ran 274ms... roughly 20 times as long.
Enlightening.
So, it would be safe to say that vars are considerably faster, as
Jacque said. But, at least until I learn some new techniques, are way
more limited, to my thinking.
But then, here is something interesting, based on an adaptation of your
benchmark script (note that the array even uses a slower repeat
structure.) -
Props: 274
Vars: 12
Array: 129
on mouseUp
put 10000 into N
--
put the millisecs into s
repeat n
set the uTest of this stack to "hello world"
get the uTest of this stack
end repeat
put the millisecs - s into s1
--
put the millisecs into s
repeat n
put "Hello World" into tMyVar
get tMyVar
end repeat
put the millisecs - s into s2
--
put the milliSecs into s
repeat with i = 1 to n
put "Hello world" into tMyVar[i]
get tMyVar[i]
end repeat
put the milliSecs - s into s3
put "Props: "&s1 &cr& "Vars: "& s2 &CR& "Array: " & s3
end mouseUp
--
Troy
RPSystems, Ltd.
http://www.rpsystems.net
More information about the use-livecode
mailing list