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}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|