Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Using Perl saves time....

by greenFox (Vicar)
on Jul 19, 2005 at 08:55 UTC ( [id://476006]=note: print w/replies, xml ) Need Help??


in reply to Re: Using Perl saves time....
in thread Using Perl saves time....

Your code is slow too, you need a suitably large directory to test properly-

$ time perl -e 'print scalar(()=glob"*"),$/' 136631 real 0m4.810s user 0m3.340s sys 0m1.320s $ time perl -le 'opendir f, $ARGV[0] or die $!;++$c while readdir f; p +rint $c' . 136633 real 0m0.440s user 0m0.400s sys 0m0.040s

--
Murray Barton
Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho

Replies are listed 'Best First'.
Re^3: Using Perl saves time....
by sh1tn (Priest) on Jul 19, 2005 at 10:47 UTC
    You are right - glob is slower than readdir.
    My point is the short one-liner. Otherwise:
    # time ls | wc -l 99999 real 0m1.850s user 0m1.590s sys 0m0.210s # time perl -e '@_ = glob"*";print$#_' 99998 real 0m1.462s user 0m0.880s sys 0m0.570s # the best alternative: # time perl -MIO::Dir -e '@_ = IO::Dir->new(".")->read;print$#_' 100000 real 0m0.680s user 0m0.570s sys 0m0.100s


Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://476006]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 01:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found