Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: do/redo or for(;;): what's Kosher?

by robin (Chaplain)
on Jan 04, 2002 at 20:02 UTC ( #136288=note: print w/ replies, xml ) Need Help??


in reply to Re: do/redo or for(;;): what's Kosher?
in thread do/redo or for(;;): what's Kosher?

The constructs for (;;), while (1), and until (0) all generate exactly the same opcodes. If one is consistently faster than the other, that might perhaps tell you more about your benchmarking procedure than about the code you're trying to benchmark. :-) I tried running your code with the time limit increased from 5 CPU seconds to 60 CPU seconds, and got:

Rate {; redo;} while (1) for (;;) {; redo;} 17.7/s -- -4% -5% while (1) 18.5/s 4% -- -0% for (;;) 18.5/s 5% 0% --
suggesting that while and for are the same speed after all, which is something of a relief.


Comment on Re: Re: do/redo or for(;;): what's Kosher?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2014-11-29 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls