Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: Re: Teach him a lesson with facts

by hardburn (Abbot)
on Feb 22, 2003 at 20:23 UTC ( [id://237801]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Teach him a lesson with facts
in thread Teach him a lesson with facts

I think you're misunderstanding how optimization works. Take the code posted above:

for (0..1_000_000) { $x=$_+1; }

Or in C or Java:

int i, x; for(i = 0; i < 1000000; i++) { x = i + 1; }

C and Java optimizers can turn the above into this:

int x = 1000000;

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.

----
Reinvent a rounder wheel.

Note: All code is untested, unless otherwise stated

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://237801]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-23 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found