Next Making Programs Faster 95

Getting the Wrong Answer as Quickly as Possible

       #!/usr/bin/perl -w
       use Benchmark;
       my $code = q{"x" . "y"};
       timethese(8000, {
            'Slow Eval' => sub {eval  $code  },
            'Fast Eval' => sub {eval {$code} }
       });
       Benchmark: timing 8000 iterations of Fast Eval, Slow Eval...
        Fast Eval:  0 wallclock secs 
               ( 0.02 usr +  0.00 sys =  0.02 CPU) 
               @ 400000.00/s (n=8000)
        Slow Eval:  4 wallclock secs 
               ( 3.43 usr +  0.00 sys =  3.43 CPU) 
               @ 2332.36/s (n=8000)

Next Copyright © 2003 M. J. Dominus