Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
P is for Practical
 
PerlMonks  

•Re: Benchmark, -s versus schwartzian

by merlyn (Sage)
on Aug 22, 2004 at 17:45 UTC ( #384955=note: print w/ replies, xml ) Need Help??


in reply to Benchmark, -s versus schwartzian

How many files do you have in /bin?

Oh, and the glob of /bin is going to dominate the times. Maybe you want to move that out of the loops.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.


Comment on •Re: Benchmark, -s versus schwartzian
Re^2: Benchmark, -s versus schwartzian
by Aristotle (Chancellor) on Aug 22, 2004 at 18:40 UTC

    Something to change in the next revision of the book? :-)

    Makeshifts last the longest.

      Well, I meant what I said in the answer. On my laptop, doing the glob inside the loop on 33 elements made the ST the winner.

      But yes, suggesting that the filenames be captured once might make sense for the 2ed of the book.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

Re^2: Benchmark, -s versus schwartzian
by Darby (Sexton) on Aug 22, 2004 at 20:42 UTC
    Aha! Moving the glob out of the loops (using Ambrus's code) gave the expected results:
    /etc/ contains 311 files Benchmark: running Ordinary, Schwartzian, Strange for at least 5 CPU s +econds... Ordinary: 5 wallclock secs ( 1.47 usr + 4.09 sys = 5.56 CPU) @ 99 +.28/s (n=552) Schwartzian: 5 wallclock secs ( 3.95 usr + 1.13 sys = 5.08 CPU) @ 3 +33.46/s (n=1694) Strange: 5 wallclock secs ( 4.01 usr + 1.12 sys = 5.13 CPU) @ 35 +9.06/s (n=1842)

    /bin/ contains 111 files Benchmark: running Ordinary, Schwartzian, Strange for at least 5 CPU s +econds... Ordinary: 5 wallclock secs ( 1.30 usr + 3.98 sys = 5.28 CPU) @ 34 +8.86/s (n=1842) Schwartzian: 6 wallclock secs ( 3.97 usr + 1.45 sys = 5.42 CPU) @ 9 +79.89/s (n=5311) Strange: 5 wallclock secs ( 3.84 usr + 1.46 sys = 5.30 CPU) @ 11 +45.85/s (n=6073)
    One thing, If I used "/usr/bin" or any other path with a '/' in the middle it went haywire. Thanks a lot for all the help everybody!

      This still does not explain the original results. I think that even with the glob in the loop, the Schwartzian transform should be faster. (I couldn't reproduce those results, the Schwartzian was faster for me even with your original code.)

      One thing, If I used "/usr/bin" or any other path with a '/' in the middle it went haywire.

      That's wierd.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2014-04-16 05:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (414 votes), past polls