Re: [SPOILER] Solution to Perl 'Expert' Quiz-of-the-Week #22
"Randy W. Sims" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.qotw.discuss |
|---|---|
| Message-ID | <[email protected]> |
John J. Trammell wrote:
> On Mon, Aug 30, 2004 at 04:44:12AM -0400, Randy W. Sims wrote:
> [snip]
>
>>Benchmark: timing 10 iterations of compound, simple...
>>compound: 866 wallclock secs (726.63 usr + 0.94 sys = 727.57 CPU) @ > 0.01/s (n=10)
>>simple: 4 wallclock secs ( 3.52 usr + 0.05 sys = 3.58 CPU) @ > 2.80/s (n=10)
>> s/iter compound simple
>>compound 72.8 -- -100%
>>simple 0.358 20246% --
>
>
> That's odd--when I run that benchmark, I get about a factor of two:
>
> Benchmark: timing 20 iterations of compound, simple...
> compound: 8 wallclock secs ( 7.70 usr + 0.06 sys = 7.76 CPU) @ 2.58/s (n=20)
> simple: 4 wallclock secs ( 4.13 usr + 0.05 sys = 4.18 CPU) @ 4.78/s (n=20)
> Rate compound simple
> compound 2.58/s -- -46%
> simple 4.78/s 86% --
>
> That's on perl 5.6.1; on 5.8.4 the difference is a little more
> pronounced (more like a factor of 3).
Yeah, I just ran it on my Debian laptop w/ perl 5.8.4, and I get results
similar to yours:
s/iter compound simple
compound 1.07 -- -55%
simple 0.484 120% --
The original was run on Windows 2000 w/ perl 5.6.1. Similar processors,
but run times are very different. I suspect the difference must be due
to file caching. From observing the run on linux, it /seems/ like the
entire word file is remaining in the file cache, where on Windows it
reread the file each time. That's my best guess at what's going on, but
it is just a guess.
Randy.