Cislo ve skalaru?

Honza Pazdziora adelton na informatics.muni.cz
Úterý Únor 16 13:18:01 MET 1999


> 
> :> > A co je spatneho na tom RE? 
> 
> vykon ..

No, ono to neni az tak hrozne:

$ perl
use Benchmark;
my $a = '00243';
timethese(50000, {
        'plus' => sub { $a + 0 == $a },
        'regexp' => sub { $a =~ /^\d+$/ },
        } );
__END__
Benchmark: timing 50000 iterations of plus, regexp...
      plus:  5 secs ( 1.31 usr  0.01 sys =  1.32 cpu)
    regexp:  9 secs ( 2.79 usr  0.02 sys =  2.81 cpu)

na MIPSu a

Benchmark: timing 500000 iterations of plus, regexp...
      plus:  4 wallclock secs ( 3.89 usr +  0.00 sys =  3.89 CPU)
    regexp:  5 wallclock secs ( 4.77 usr +  0.00 sys =  4.77 CPU)

na UltraSparcu, cili rekneme maximalne dvakrat pomalejsi, coz se da
prezit. Navic ten regexp dokazete snadneji modifikovat i na jine
pripady, ktere byste chtel zachytit, treba jen integer, jen kladne,
ap.

------------------------------------------------------------------------
 Honza Pazdziora | adelton na fi.muni.cz | http://www.fi.muni.cz/~adelton/
 make vmlinux.exe			-- SGI Visual Workstation Howto
------------------------------------------------------------------------


Další informace o konferenci Perl