in reply to RE: Re: A Not so Simple Append
in thread A Not so Simple Append
I tried it and wow:
Why is the one so much faster than the other?use strict; use Benchmark; use vars qw(%test); %test = ( push => sub { my @tmp; push @tmp, "bar" foreach 1..10000; }, unshift => sub { my @tmp; unshift @tmp, "bar" foreach 1..10000; }, ); timethese (-5, \%test); __END__ Benchmark: running push, unshift, each for at least 5 CPU seconds... push: 5 wallclock secs ( 5.46 usr + 0.05 sys = 5.51 CPU) @ 17 +.42/s (n=96) unshift: 8 wallclock secs ( 8.08 usr + 0.11 sys = 8.19 CPU) @ 0 +.73/s (n=6)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE (tilly) 3 (less?): A Not so Simple Append
by extremely (Priest) on Oct 03, 2000 at 05:25 UTC | |
by tilly (Archbishop) on Oct 03, 2000 at 06:37 UTC |