Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Which is faster ?

by starbolin (Hermit)
on Jun 04, 2008 at 17:32 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2022-10-04 23:11 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (19 votes). Check out past polls.