http://qs321.pair.com?node_id=690192


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}