On Tue, Jul 01, 2003 at 01:18:46PM -0400, Robin Norwood wrote:
> David Storrs <[EMAIL PROTECTED]> writes:
>
> keys_compare might be slightly better for small sets, but for large
> sets, short_circuit is the way to go.
>
> I initialized my @array like so:
>
> my @array;
> for (1 .. 5000) { push @array, int((rand) * 10000); }
>
> And I only ran 10,000 iterations, since I wanted it to finish before I
> got bored with the whole thing.
>
> Results:
>
> Benchmark: timing 10000 iterations of grep_compare, keys_compare, short_circuit...
>
> grep_compare: 140 wallclock secs (136.80 usr + 0.37 sys = 137.17 CPU) @ 72.90/s
> (n=10000)
>
> keys_compare: 127 wallclock secs (126.35 usr + 0.21 sys = 126.56 CPU) @ 79.01/s
> (n=10000)
>
> short_circuit: 5 wallclock secs ( 4.67 usr + 0.01 sys = 4.68 CPU) @ 2136.75/s
> (n=10000)
Cool. Thanks; this bears out my original feeling that short_circuit
should be the way to go (and saves me the trouble of futzing with it
when I get home tonight :> ).
--Dks
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]