Uhm, I probably hit another dark corner: #!/usr/bin/perl
use strict;
use warnings;
use Benchmark qw( cmpthese );
cmpthese -2, {
by_substr => sub {
my $nomedir = '20070502-11';
my $anno = substr $nomedir, 0, 4;
my $mese = substr $nomedir, 4, 2;
my $giorno = substr $nomedir, 6, 2;
my $progressivo = substr $nomedir, 9, 2;
},
by_unpack => sub {
my $nomedir = '20070502-11';
my ($anno, $mese, $giorno, $progressivo)
= unpack 'A4 A2 A2 x A2', $nomedir;
},
};
poletti@PolettiX:~/sviluppo/perl$ /opt/perl-5.8.8/bin/perl numstat.pl
Rate by_unpack by_substr
by_unpack 417553/s -- -32%
by_substr 613303/s 47% --
poletti@PolettiX:~/sviluppo/perl$ /opt/perl-5.10.0/bin/perl numstat.pl
Rate by_unpack by_substr
by_unpack 372754/s -- -34%
by_substr 565358/s 52% --
poletti@PolettiX:~/sviluppo/perl$ /opt/perl-5.8.8/bin/perl numstat.pl
Rate by_unpack by_substr
by_unpack 415531/s -- -33%
by_substr 616325/s 48% --
poletti@PolettiX:~/sviluppo/perl$ /opt/perl-5.10.0/bin/perl numstat.pl
Rate by_unpack by_substr
by_unpack 374480/s -- -33%
by_substr 562716/s 50% --
poletti@PolettiX:~/sviluppo/perl$ /opt/perl-5.8.8/bin/perl numstat.pl
Rate by_unpack by_substr
by_unpack 415531/s -- -33%
by_substr 616325/s 48% --
poletti@PolettiX:~/sviluppo/perl$ /opt/perl-5.10.0/bin/perl numstat.pl
Rate by_unpack by_substr
by_unpack 369821/s -- -34%
by_substr 562716/s 52% --
I made some repeated calls just to be sure not to hit some "spots".
Update: I forgot to say that I'm under Linux, and that the two perls where compiled with the same configure options (-des for 5.8.8, and a more verbose -de for 5.10.0).
Hey! Up to Dec 16, 2007 I was named frodo72, take note of the change! Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
Io ho capito... ma tu che hai detto?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|