perl -MBenchmark -de0
Loading DB routines from perl5db.pl version 1.28
Editor support available.
Enter h or `h h\' for help, or `man perldebug\' for more help.
main:
-e:1): 0
DB<1> sub a1 () { my @massiv = ("A", "B", "C", "D", "E", "F"); my $massiv_t = $massiv[0]; my $dannie=2; $massiv[0] = $massiv[$dannie]; $massiv[$dannie] = $massiv_t; }
DB<2> sub a2 () { my @massiv = ("A", "B", "C", "D", "E", "F"); my $dannie=2; unshift @massiv,splice(@massiv,$dannie-1,1); }
DB<3> timethese (100000,{ "simple" => \\&a1, "unshift" => \\&a2 })
Benchmark: timing 100000 iterations of simple, unshift...
simple: 0 wallclock secs (-0.01 usr + 0.00 sys = -0.01 CPU) @ -10000000.00/s (n=100000)
(warning: too few iterations for a reliable count)
unshift: 0 wallclock secs ( 0.04 usr + 0.00 sys = 0.04 CPU) @ 2500000.00/s (n=100000)
(warning: too few iterations for a reliable count)
DB<4> timethese (1000000,{ "simple" => \\&a1, "unshift" => \\&a2 })
Benchmark: timing 1000000 iterations of simple, unshift...
simple: 1 wallclock secs (-0.10 usr + 0.00 sys = -0.10 CPU) @ -10000000.00/s (n=1000000)
(warning: too few iterations for a reliable count)
unshift: 1 wallclock secs ( 0.35 usr + 0.00 sys = 0.35 CPU) @ 2857142.86/s (n=1000000)
(warning: too few iterations for a reliable count)