Search code examples
actionscript-3actionscriptspeed-test

"not less than" versus "greater or equal to" speed


I was wondering if someone knew or has one of those accurate speed tests could test "not less than" versus "greater or equal to" speed in Actionscript 3 (Air 2.5 if that makes a difference)?

I have virtual machines running on this computer and I am getting very inaccurate results.

Using it as such

if ( !(__index < _vector.length) ) return;

or

if ( __index >= _vector.length ) return;

I would have thought the first one, since all its doing is 1 test and then reversing it, but actionscript 3 has some of those quirks where you can never be sure.


Solution

  • There shouldn't be a difference in speed, in theory. ActionScript uses the nanojit JIT library to compile code, and I know for a fact (having worked on that code before in Mozilla's JavaScript engine, which shares nanojit with Adobe's ActionScript) that the code to implement comparisons will transform simple conversions like inversion of a comparison into the inverse comparison. So in theory the only difference is another cycle or two spent to compile the code. This is not worth worrying about.

    On the other hand, modern CPUs are complex beasts, and infinitesimal perturbations can make notable differences. So while I'd lay strong odds on there being no difference between the two, I wouldn't bet the farm on it.