[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Duff's Device in Perl





unrolling the whole thing and evalling it makes it about 10X slower
sub Nicol {

    my $from = shift;  # real life would use reference here, this is a
demo
    my $to;            # dummy: simulate write to serial i/o port
    my $i = 0;

    eval '$to = (substr $from, $i++, 1);' x length $from;

};

use Benchmark;

timethese(10000, {
        Yahas26 => 'Yahas("ABCDEFGHJiKLMNOPQRSTUVWXYZ")',
        Nicol26 => 'Nicol("ABCDEFGHJiKLMNOPQRSTUVWXYZ")'
}


____________________________________________________________________
                            David Nicol 816.235.1187 nicold@umkc.edu
"With diligence it is possible to make anything run slowly." -- Duff

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe