in reply to Re: round-robin on varying sequence
in thread round-robin on varying sequence
To provide fair comparison, here are the results I got running your original benchmark on my system (note the increased iteration count -- my system is 5X faster):# the fix: @items = grep { my $keep = !exists $del{$_}; $i++; $index -= ($i < $index) unless $keep; $keep } @items; # the results Benchmark: timing 100000 iterations of BrowserUk, dpuu... BrowserUk: 13 wallclock secs (13.72 usr + 0.00 sys = 13.72 CPU) @ 72 +88.63/s (n=100000) dpuu: 10 wallclock secs ( 9.88 usr + 0.00 sys = 9.88 CPU) @ 10 +117.36/s (n=100000) Rate BrowserUk dpuu dpuu 10117/s 39% -- BrowserUk 7289/s -- -28%
in constrast to your +25/-20%. --DaveBenchmark: timing 100000 iterations of BrowserUk, dpuu... BrowserUk: 10 wallclock secs ( 9.26 usr + 0.00 sys = 9.26 CPU) @ 10 +795.64/s (n=100000) dpuu: 10 wallclock secs ( 9.87 usr + 0.01 sys = 9.88 CPU) @ 10 +118.39/s (n=100000) Rate dpuu BrowserUk dpuu 10118/s -- -6% BrowserUk 10796/s 7% --
Update: The required optimization is this twisted expression:
@items = grep { ++$i && !exists $del{$_} || ($index -= $i-1 <= $index) + && 0 } @items;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: round-robin on varying sequence
by BrowserUk (Patriarch) on Sep 08, 2002 at 00:12 UTC | |
by dpuu (Chaplain) on Sep 08, 2002 at 00:38 UTC | |
by BrowserUk (Patriarch) on Sep 08, 2002 at 00:58 UTC |