Help for this page

Select Code to Download


  1. or download this
    $ perl -MBenchmark -e'timethese(10000, { map => sub { @_ = map 1, 1..1
    +000 }, x => sub { @_ = (1)x1000 }})'
    
    Benchmark: timing 10000 iterations of map, x...
    ...
    Benchmark: timing 1000000 iterations of map, x...
           map: 17 wallclock secs (15.55 usr +  0.15 sys = 15.70 CPU) @ 63
    +694.27/s (n=1000000)
             x:  9 wallclock secs ( 8.44 usr +  0.11 sys =  8.55 CPU) @ 11
    +6959.06/s (n=1000000)
    
  2. or download this
    $ perl -MO=Deparse,-x7 -e'timethese(1000000, { map => sub { @_ = map 1
    +, 1..5 }, x => sub { @_ = (1)x5 }})'
    
    timethese 1000000, {'map', sub {
    ...
    }
    };
    -e syntax OK