Dear Masters,
I have the following benchmark snippets.
my $r = timethese( -5, { list => sub { code1($fstr); }, enum => sub { code2($fstr); } } ); cmpthese $r;
Now I have difficulty in interpreting the result below:
Benchmark: running enum, list for at least 5 CPU seconds... enum: 5 wallclock secs ( 3.55 usr + 1.74 sys = 5.29 CPU) @ 50 +1.89/s (n=2655) list: 5 wallclock secs ( 5.32 usr + 0.00 sys = 5.32 CPU) @ 16 +68.23/s (n=8875) Rate enum list enum 502/s -- -70% list 1668/s 232% --
My questions are:
  1. from 'cmpthese' results it is clear that "list" is more than twice faster than "enum". But looking at the wallclock value from 'timethese' it shows that both of them are close to each other in their total time, even more the usertime for "enum" is shorter than "list". Now which is the correct benchmark should we use 'cmpthese' or 'timethese'? And which one is actually faster "enum" or "list"?
  2. What does "n" value refer to in 'timethese' output?


---
neversaint and everlastingly indebted.......

In reply to Interpreting Benchmark's "cmpthese" and "timethese" by neversaint

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.