in reply to Re: Reading entire file into scalar: speed differences?
in thread Reading entire file into scalar: speed differences?

Using a single sysread() helps you win a probabilistic scheduling game, where you are competing against other programs that are also trying to move a disk head to fetch data. Moving a disk head is expensive, and if you can get your entire read satisfied with minimal intervening moves, you win. If you block during a read() and another program (or set of programs) gets requests queued that cause the head to move, you might lose unless the OS is smart enough to be doing read-ahead caching.

If you're the only person on the box, Benchmark tests are rather suspect, since there's not a lot of competition for the disk head. It would be much more interesting to see how the benchmarks differed if you were to run 20 of them simultaneously.

Replies are listed 'Best First'.
Re: Re: Re: Reading entire file into scalar: speed differences?
by belg4mit (Prior) on Jan 25, 2002 at 07:52 UTC
    # uname -a SunOS host 5.8 Generic_108528-08 sun4u sparc SUNW,Sun-Fire-280R #uptime #shortly before running the test 9:41pm up 103 day(s), 13:13, 131 users, load average: 0.05, 0.07, + 0.11 Benchmark: timing 50 iterations of join, while... join: 2 wallclock secs ( 2.09 usr + 0.03 sys = 2.11 CPU) @ 23 +.64/s (n=50) while: 2 wallclock secs ( 1.87 usr + 0.04 sys = 1.92 CPU) @ 26 +.10/s (n=50) Rate join while join 23.6/s -- -9% while 26.1/s 10% -- #Required more iterations for accuracy on this machine Benchmark: timing 5000 iterations of slurp, sys... slurp: 4 wallclock secs ( 1.61 usr + 2.30 sys = 3.91 CPU) @ 12 +80.08/s (n=5000) sys: 2 wallclock secs ( 0.12 usr + 1.86 sys = 1.99 CPU) @ 25 +16.36/s (n=5000) slurp 1280/s -- -49% sys 2516/s 97% --

    --
    perl -pe "s/\b;([st])/'\1/mg"