I got these results.use Benchmark; @base=qw/one two three four five six seven/; timethese(1_000_000,{ '$'=>sub {($s1,$s2,$s3,$s4,$s5,$s6,$s7)=@base;}, '@'=>sub{@s=@base;} });
odd? Yeah.. However, when i tried this code:Benchmark: timing 1000000 iterations of $, @... $: 3 wallclock secs ( 2.86 usr + 0.00 sys = 2.86 CPU) @ 34 +9650.35/s (n=1000000) @: 11 wallclock secs (10.16 usr + 0.00 sys = 10.16 CPU) @ 98 +425.20/s (n=1000000)
i got these results:use Benchmark; my $sub=eval 'sub {('.join(',',map{'$s'.$_}1..1000).')=@base}'; @base=(1..1_000); timethese(1_000_000,{ '$'=>$sub, '@'=>sub{@s=@base;} });
Anyone have a brilliant explanation? (sorry for the pageful of $sXs, but i wanted to make the script just copy and paste).Benchmark: timing 1000000 iterations of $, @... $: 131 wallclock secs (130.77 usr + 0.00 sys = 130.77 CPU) @ 7647.01/s (n=1000000) @: 149 wallclock secs (149.56 usr + 0.00 sys = 149.56 CPU) @ 6686.28/s (n=1000000)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: list of scalars vs arrays, speed?
by demerphq (Chancellor) on May 02, 2002 at 11:08 UTC | |
by BUU (Prior) on May 02, 2002 at 12:44 UTC | |
|
Re: list of scalars vs arrays, speed?
by Matts (Deacon) on May 02, 2002 at 07:47 UTC | |
by pdcawley (Hermit) on May 02, 2002 at 09:22 UTC | |
|
Re: list of scalars vs arrays, speed?
by dws (Chancellor) on May 02, 2002 at 05:45 UTC | |
by belg4mit (Prior) on May 02, 2002 at 06:21 UTC | |
by dws (Chancellor) on May 02, 2002 at 06:27 UTC | |
by belg4mit (Prior) on May 02, 2002 at 06:32 UTC | |
|
Re: list of scalars vs arrays, speed?
by perrin (Chancellor) on May 02, 2002 at 16:00 UTC | |
|