Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Which is faster ?

by starbolin (Hermit)
on Jun 04, 2008 at 17:32 UTC ( [id://690192]=note: print w/replies, xml ) Need Help??


in reply to Which is faster ?

The piece of code is just way to small to even think about profiling. The CPU can pack a compare, branch and constant into one token in one stage of one ALU pipeline and still have room left over for the fetch of $flag. In the time it take for a memory access, the CPU can have executed the compare/constant pair a hundred times. In fact, assuming a short while() loop, say:  for(my $i=10;0>=$i;$i++){ .. some small code ... }the CPU will have used speculative execution to process the complete next iteration ( $i = 0 ) before even branching out of the loop ( it throws away the results. )

Benchmarking is more for question like: "Is heap-sort faster than bubble-sort"" and "Can I get this line processed before the next line comes it?". This is an area where I could agree with dragonchild in his post CPU cycles DO NOT MATTER!; that is, if the title was less assertive:-)>


s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-19 23:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found