in reply to What could cause excessive page faults?
is way faster than:perl -MTime::HiRes=time -wE"my $t=time; my @a=1..1e6;say time-$t;
because the map generates an anon array that is an "extra step" and that array is copied to @a.perl -MTime::HiRes=time -wE"my $t=time; my @a=map $_,1..1e6;say time-$ ++t;
In your later code, you have a map within a map which is similar to a foreach within a foreach. So it is going to run like 1 million times slower.
On my machine...
C:\Projects>perl -MTime::HiRes=time -wE"my $t=time; my @a=(1..1e6);say + time-$t;" 0.0974979400634766 C:\Projects>perl -MTime::HiRes=time -wE"my $t=time; my @a=map $_,1..1e +6;say time-$t;" 0.337559938430786 C:\Projects>perl -MTime::HiRes=time -wE"my $t=time; my @a=map {$_}1..1 +e6;say time-$t;" 0.339046001434326
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: What could cause excessive page faults?
by ikegami (Patriarch) on Mar 11, 2010 at 03:24 UTC | |
by Marshall (Canon) on Mar 11, 2010 at 03:49 UTC | |
by fullermd (Vicar) on Mar 11, 2010 at 06:34 UTC | |
by ikegami (Patriarch) on Mar 11, 2010 at 15:42 UTC | |
by Marshall (Canon) on Mar 11, 2010 at 08:58 UTC |