in reply to Re: Myth busted: Shell isn't always faster than Perl
in thread Myth busted: Shell isn't always faster than Perl

I'd say it's a wash. Trying it several times, the best times I got were:
time perl -MFile::Find -e'finddepth sub { unlink if -f }, @ARGV' /tmp
real    0m3.111s
user    0m0.821s
sys     0m2.233s
time find /tmp -type f | xargs rm
real    0m3.312s
user    0m0.760s
sys     0m2.511s
And the varied widely - anywhere up to 5 seconds.

Remember: There's always one more bug.

Replies are listed 'Best First'.
Re^3: Myth busted: Shell isn't always faster than Perl
by zentara (Cardinal) on Dec 30, 2005 at 21:17 UTC
    I tested my original script with the
    return if -d; unlink $_
    against the golfed
    unlink $_ if -f;
    and the golfed -f test seems to be a bit slower. Maybe because unlink somehow gets called for each directory then stopped? Whereas the 'return if -d ' returns immediately. BUT the improved shell with null
    find . -type f -print0 | xargs -0 rm
    seems to win :-(
    time -d-test Gtk3 real 0m0.412s user 0m0.074s sys 0m0.337s time -f-test Gtk3 real 0m0.478s user 0m0.076s sys 0m0.388s time find . -type f -print0 | xargs -0 rm real 0m0.334s user 0m0.012s sys 0m0.321s

    I'm not really a human, but I play one on earth. flash japh