Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Benchmark tips

by TheDamian (Priest)
on Apr 14, 2003 at 22:02 UTC ( #250428=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Re: Making a match
in thread Making a match

(Sigh. I just can help myself, can I? Always with the advice... ;-)

Two suggestions for using Benchmark:

  1. If you're using long names for each test, pad the names to the same length with extra spaces on the left. Then your results are much easier to read and compare:
    Hash Exists Hit: 4 wallclock secs @ 1204819.28/s (n=10000 +00) Hash Defined Hit: 3 wallclock secs @ 2173913.04/s (n=10000 +00) Hash Exists Miss: 1 wallclock secs @ 1515151.52/s (n=10000 +00) Hash Defined Miss: 3 wallclock secs @ 1492537.31/s (n=10000 +00) Hash Assigned Miss Truth: 6 wallclock secs @ 1515151.52/s (n=10000 +00) Hash Assigned Hit Equality: 4 wallclock secs @ 1149425.29/s (n=10000 +00) Hash Assigned Hit Truth: 5 wallclock secs @ 970873.79/s (n=100000 +0) Hash Assigned Miss Equality: 6 wallclock secs @ 877192.98/s (n=100000 +0)
  2. Use cmpthese instead of timethese. That adds a handy comparison matrix at the end of your test results (though this suggestion works much better with shorter names):
    Rate HDH HAHE HAME HEH HAMT HDM HAHT HEM HDH 1111111/s -- -0% -4% -21% -24% -28% -30% -39% HAHE 1111111/s 0% -- -4% -21% -24% -28% -30% -39% HAME 1162791/s 5% 5% -- -17% -21% -24% -27% -36% HEH 1408451/s 27% 27% 21% -- -4% -8% -11% -23% HAMT 1470588/s 32% 32% 26% 4% -- -4% -7% -19% HDM 1538462/s 38% 38% 32% 9% 5% -- -3% -15% HAHT 1587302/s 43% 43% 37% 13% 8% 3% -- -13% HEM 1818182/s 64% 64% 56% 29% 24% 18% 15% --


Comment on Benchmark tips
Select or Download Code
Re: Benchmark tips
by TheDamian (Priest) on Apr 14, 2003 at 22:43 UTC
    WRT suggestion 1: just thought I should mention that I was, of course, far too Lazy to actually align them myself:
    use List::Util 'max'; sub align { my ($hash) = @_; my $len = max map length, keys %$hash; $hash->{sprintf "%${len}s", $_} = delete $hash->{$_} for keys %$hash; return $hash; } cmpthese(10000, align { 'Bacon, Lettuce, & Tomato' => sub {...}, 'Ham on Rye' => sub {...}, 'Spam' => sub {...}, # etc. });

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (18)
As of 2014-07-11 19:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (235 votes), past polls