Mike, that sounds very reasonable to me.
What I've been able to ascertain is reading and writing to the register
(in the case of (--i -(-1)) is significantly faster than reading and
writing to a variable (in the case of (i--)) that the first case's
additional instruction to subtract doesn't outweigh the gain.
I guess it's kind of like a Porsce 911 is so much faster than a Ford
Festiva that adding baggage to a luggage rack to make up for the lack of
storage won't slow it down enough to lose in a race. Likewise, just
because the extra instruction of subtraction adds another line of code,
it doesn't mean it will run slower if the other lines can make up for it.
I wonder if there is a reference online that shows how many relative
cycles each instruction takes compared to one another. Aside from the
one link for Flasm that Steven posted I haven't found much. I guess I
can compile a bunch of different tests using various statements like
"push" and "setVariable" and see the performance of each. I'm sure this
has been done to death so I'd rather just read the findings. I guess
this is my punishment for getting art degrees.
Now whether I would use (--i -(-i)) over (i--) in practice is a
different issue. My guess is I would use the former if FPS was a real
concern and the later if readability was more of a priority.
James O'Reilly
www.jamesor.com
Mike Keesey wrote:
My guess would be that postincrement it takes longer because it needs to
store and return the original value, while preincrement only needs to
return the result after performing the operation. But that's only a
guess.
―
Mike Keesey
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com