So I got around to benchmarking today. I was struck by the
large variability in the benchmarks--2 orders of magnitude
difference. So can someone explain why tadman's and MeowChow's
subs are so much faster?
tadman original:
|
timethis 100000: 70 wallclock secs (70.00 usr + 0.02 sys = 70.02 CPU) @ 1428.16/s (n=100000)
|
MeowChow:
|
timethis 100000: 13 wallclock secs (12.25 usr + 0.00 sys = 12.25 CPU) @ 8163.27/s (n=100000)
|
no_slogan:
|
timethis 100000: 81 wallclock secs (78.22 usr + 0.04 sys = 78.26 CPU) @ 1277.79/s (n=100000)
|
srawls:
|
timethis 100000: 56 wallclock secs (53.80 usr + 0.07 sys = 53.87 CPU) @ 1856.32/s (n=100000)
|
tachyon:
|
timethis 100000: 90 wallclock secs (89.07 usr + 0.06 sys = 89.13 CPU) @ 1121.96/s (n=100000)
|
tadman golf:
|
timethis 100000: 1 wallclock secs ( 0.83 usr + 0.00 sys = 0.83 CPU) @ 120481.93/s (n=100000)
|
Scott
Experimental method:
I placed each sub in a holder script and executed it. The
script looked like this:
#!/usr/bin/perl
use Benchmark;
my $iter=100000;
while (<DATA>){ #tadman original
timethis($iter, sub {
$_=pop;y/UCAG/0123/;s/(.)(.)(.)/substr
"FFLLSSSSYY..CC.WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG"
,$1<<4|$2<<2|$3,1/ge;y/0123//d;$_
});
}
__DATA__
yada yada... the CFTR mRNA from above.
-
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.
|