q( #These "cripple" C-style and push to make it a fair fight, by reinitializing the array each time C-style: 1 wallclock secs ( 0.57 usr + 0.04 sys = 0.60 CPU) @ 16528.93/s (n=10000) destroy: 337 wallclock secs (325.85 usr + 0.28 sys = 326.13 CPU) @ 30.66/s (n=10000) push: 1033 wallclock secs (983.44 usr + 0.85 sys = 984.30 CPU) @ 10.16/s (n=10000) #These do not Benchmark: timing 10000 iterations of C-style, destroy, push... C-style: 1 wallclock secs ( 0.47 usr + 0.03 sys = 0.51 CPU) @ 19762.85/s (n=10000) destroy: 339 wallclock secs (321.60 usr + 0.32 sys = 321.92 CPU) @ 31.06/s (n=10000) push: 655 wallclock secs (641.02 usr + 0.54 sys = 641.56 CPU) @ 15.59/s (n=10000) ); open OUT, ">/dev/null"; select(OUT); $|++; select(STDOUT); @in = (1,2,3,4,5,6,7,8,9,0); use Benchmark; timethese(10000, { 'C-style' => '#@in = (1,2,3,4,5,6,7,8,9,0); for my $i ( 0 .. $#in ) { $i % 2 ? $out2[int($i/2)] = $in[$i] : $out1[$i/2] = $in[$i]; } print OUT @out1,"\n"; print OUT @out2,"\n";', 'push' => '#@in = (1,2,3,4,5,6,7,8,9,0); for my $i ( 0 .. $#in ) { $i % 2 ? push @out2, $in[$i] : push @out1, $in[$i]; } print OUT @out1,"\n"; print OUT @out2,"\n";', 'destroy' => '@in = (1,2,3,4,5,6,7,8,9,0); while( @in ){ push @out1, shift(@in); push @out2, shift(@in); } print OUT @out1,"\n"; print OUT @out2,"\n";' });