Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: (Golf) RNA Genetic Code Translator

by scain (Curate)
on Jul 09, 2001 at 19:19 UTC ( [id://95002]=note: print w/replies, xml ) Need Help??


in reply to (Golf) RNA Genetic Code Translator

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.

Replies are listed 'Best First'.
Re^2: (Golf) RNA Genetic Code Translator
by tadman (Prior) on Jul 09, 2001 at 22:13 UTC
    I think MeowChow's would be nearly as fast, except that for reasons of brevity it performs this crazy map operation on every base-pair triplet substitution.

    On this train of thought, is there such as thing as a Benchmark-type routine that will test performance on a variety of data sizes? So many times people benchmark a variety of routines with only one set of data, which has the result of being a 1-dimensional test where there are actually 2 independent variables (function and data set size).

    In line with Big-O Notation, is it possible and/or has someone written a Benchmark-type module which would estimate what kind of O(f(n)) function would best represent how the algorithm in question scales? Certainly not trivial by any means, but not impossible either.
      This is not exactly what you asked for, but it would be easy to place several sequences in the __DATA__ chunk, one to a line, and since the timethis is in a while loop, it will iterate over each seqence. If you wanted to be really anal, you could then pipe the output to another perl program to parse and do statistics.

      Scott

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-20 16:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found