in reply to Re^2: Don't treat your numbers as strings, or Interpolation is worse than you might think
in thread Don't treat your numbers as strings, or Interpolation is worse than you might think
The difference between PV and PVIV is so small that i did not notice it in my benchmarks and thought that the numbers are CONVERTED to strings :)Rate PVIV PV IV PVIV 2065/s -- -1% -64% PV 2084/s 1% -- -64% IV 5806/s 181% 179% --
The code of the benchmark is here.
#!/usr/bin/perl use warnings; use strict; use Benchmark qw/:hireswallclock cmpthese/; my @ary = (0..10); #only IV my $len = $#ary; my @ary2 = @ary; my @ary3 =qw/0 1 2 3 4 5 6 7 8 9 10/; #only PV print "ARRAY: @ary2\n"; # IV -> PVIV cmpthese (-3, { 'IV' => sub { foreach my $i (0..$len-1) { foreach my $j ($i+1..$len) { my @permuted = @ary; @permuted[$i, $j] = @permuted[$j, $i]; } } }, 'PVIV' => sub { foreach my $i (0..$len-1) { foreach my $j ($i+1..$len) { my @permuted = @ary2; @permuted[$i, $j] = @permuted[$j, $i]; } } }, 'PV' => sub { foreach my $i (0..$len-1) { foreach my $j ($i+1..$len) { my @permuted = @ary3; @permuted[$i, $j] = @permuted[$j, $i]; } } }, });
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Don't treat your numbers as strings, or Interpolation is worse than you might think
by diotalevi (Canon) on Jul 22, 2006 at 16:23 UTC | |
|
Re^4: Don't treat your numbers as strings, or Interpolation is worse than you might think
by Marsel (Sexton) on Jul 23, 2006 at 13:06 UTC | |
by Joost (Canon) on Jul 23, 2006 at 13:21 UTC | |
by Ieronim (Friar) on Jul 23, 2006 at 16:43 UTC |