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.

In reply to Re: (Golf) RNA Genetic Code Translator by scain
in thread (Golf) RNA Genetic Code Translator by tadman

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.