Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Re: Re: Teach him a lesson with factsby hardburn (Abbot) |
on Feb 22, 2003 at 20:23 UTC ( [id://237801]=note: print w/replies, xml ) | Need Help?? |
I think you're misunderstanding how optimization works. Take the code posted above:
Or in C or Java:
C and Java optimizers can turn the above into this:
Thus totally eliminating the loop. Run your C compiler with -O0, and you'll get comparible performance to the Perl version. Why isn't this test relevent? Because the C/Java optimizer cannot always unroll loops. This is fairly common in any real-world program. ---- Note: All code is untested, unless otherwise stated
In Section
Meditations
|
|