build_new_array=>q[
my @a = 1 .. $N;
my @b;
for (@a) {
push @b, $_ if /9/;
}
],
####
edit_in_place=>q[
my @a = 1 .. $N;
my $o = 0;
for (@a) {
$a[$o++]=$_ if /9/;
}
$#a=$o-1;
],
####
$ for J in 2 3 4 5 6; do perl 1036631.pl -N=1e$J; done
Rate offset_copy grep for_splice build_new edit_in_place
offset_copy 3288/s -- -10% -27% -37% -38%
grep 3657/s 11% -- -18% -30% -31%
for_splice 4483/s 36% 23% -- -14% -16%
build_new 5191/s 58% 42% 16% -- -3%
edit_in_place 5338/s 62% 46% 19% 3% --
Rate offset_copy grep for_splice build_new edit_in_place
offset_copy 319/s -- -14% -22% -37% -40%
grep 369/s 16% -- -10% -27% -30%
for_splice 411/s 29% 11% -- -19% -22%
build_new 505/s 58% 37% 23% -- -5%
edit_in_place 528/s 66% 43% 29% 5% --
Rate for_splice offset_copy grep build_new edit_in_place
for_splice 28.6/s -- -3% -8% -35% -42%
offset_copy 29.4/s 3% -- -5% -33% -40%
grep 31.1/s 9% 6% -- -29% -37%
build_new 43.8/s 53% 49% 41% -- -11%
edit_in_place 49.1/s 72% 67% 58% 12% --
(warning: too few iterations for a reliable count)
(warning: too few iterations for a reliable count)
Rate for_splice offset_copy grep build_new edit_in_place
for_splice 0.433/s -- -86% -87% -90% -90%
offset_copy 3.00/s 593% -- -11% -28% -34%
grep 3.36/s 676% 12% -- -19% -26%
build_new 4.17/s 862% 39% 24% -- -8%
edit_in_place 4.55/s 950% 52% 35% 9% --
(warning: too few iterations for a reliable count)
(warning: too few iterations for a reliable count)
(warning: too few iterations for a reliable count)
(warning: too few iterations for a reliable count)
(warning: too few iterations for a reliable count)
s/iter for_splice offset_copy grep build_new edit_in_place
for_splice 632 -- -99% -100% -100% -100%
offset_copy 3.38 18587% -- -18% -28% -36%
grep 2.76 22785% 22% -- -12% -22%
build_new 2.43 25893% 39% 14% -- -11%
edit_in_place 2.16 29142% 56% 28% 13% --