So what is the best way to show the speed comparison in terms of it's time and not iteration/time?

Since you have

Rate enum list enum 502/s -- -70% list 1668/s 232% --

The times are 1/502 of a second vs. 1/1668 of a second. Or about 0.002s vs. 0.0006s so a difference of 0.0014s.

The block of output that I quoted compares the results while the prior output logs some details about how the computations were done. Those details aren't particularly useful for making a comparison.

You could also multiply by 1000 and say that, if you needed to call the compared bits of code 1000 times each, then one would take about 2s plus overhead while the other would take about 0.6s plus overhead. So the time difference for 1000 iterations would be about 1.4s. Note that the time for "overhead" will usually be quite a bit more than the time required to run just the compared code so that real code doing something 1000 times might have run times like 22s vs 20.6s.

Update:

from 'cmpthese' results it is clear that "list" is more than twice faster than "enum"

Actually, the "232%" means that one is more than three times faster than the other. This is a pet peave of one of my coworkers. There are several contradicting ways to report "percentage difference" and most of them lead to people making mistakes when they try to combine them. He strongly believes that it is best to avoid "percentage difference" and only ever deal in terms of simple multipliers. So he'd report the above results like:

Rate enum list enum 502/s -- 0.3 list 1668/s 3.32 --

"50% faster" means "can do it as fast as the other plus 50%" or "150% as fast" or "1.5 times as fast". So "200% faster" means "3 times as fast".

To see how confusing this can be, consider these two ways of describing the same situation:

If "A is 50% faster than B and B is 50% faster than C", how much faster is A than C? 'Obviously', "A is 125% faster than C".

If "A is 1.5 times faster than B and B is 1.5 times faster than C", how much faster is A than C? Well, 1.5*1.5 is 2.25 so, obviously, "A is 2.25 times faster than C".

- tye        


In reply to Re^3: Interpreting Benchmark 'cmpthese' and 'timethese' (time) by tye
in thread 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.