Next Making Programs Faster 160

Error Variation

        Date: Tue, 1 Jan 2002 14:46:06 +0100
        Subject: Re: How can I determine a 0 byte File
        Message-Id: <a0seef$668$05$1@news.t-online.com>
        timethese( $count, {
           'stat' => sub { (stat($filename))[7] },
           'z'    => sub {  -z $filename },
           's'    => sub {  -s $filename },
        } );
        Benchmark: timing 100000 iterations of s, stat, z...
        s:    48 wallclock secs (11.49 usr + 29.25 sys = 40.74 CPU)
              @ 2454.65/s (n=100000)
        stat: 53 wallclock secs (14.21 usr + 30.65 sys = 44.87 CPU)
              @ 2228.91/s (n=100000)
        z:    50 wallclock secs (11.66 usr + 29.76 sys = 41.42 CPU)
              @ 2414.35/s (n=100000)
        Stat indeed seems to be a little slower...
        ...but then, if -s is faster than -z, the whole difference
        may be within the error margin.

Next Copyright © 2003 M. J. Dominus