Help for this page

Select Code to Download


  1. or download this
    use Benchmark qw(:all);
    use File::Slurp;
    ...
    $read       = sub { open $file, '<', 'arq.pdf' || die $!; read $file, 
    +$data, -s 'arq.pdf'; close $file; };
    timethese(1000, { file_slurp => $file_slurp, read => $read, });
    cmpthese(1000, { file_slurp => $file_slurp, read => $read, });
    
  2. or download this
    Benchmark: timing 1000 iterations of file_slurp, read...
    file_slurp:  1 wallclock secs ( 0.43 usr +  0.31 sys =  0.74 CPU) @ 13
    +51.35/s (n=1000)
    ...
                 Rate       read file_slurp
    read        192/s         --       -86%
    file_slurp 1333/s       595%         --
    
  3. or download this
    file_slurp: 44 wallclock secs (15.99 usr + 26.40 sys = 42.39 CPU) @ 23
    +.59/s (n=1000)
          read: 23 wallclock secs ( 9.12 usr + 13.67 sys = 22.79 CPU) @ 43
    +.88/s (n=1000)
    ...
                 Rate file_slurp       read
    file_slurp 23.6/s         --       -46%
    read       43.6/s        85%         --
    
  4. or download this
    file_slurp: 46 wallclock secs (16.01 usr + 26.25 sys = 42.26 CPU) @ 23
    +.66/s (n=1000)
          read: 25 wallclock secs ( 9.00 usr + 13.91 sys = 22.91 CPU) @ 43
    +.65/s (n=1000)
    ...
                 Rate file_slurp       read
    file_slurp 23.7/s         --       -46%
    read       43.5/s        84%         --