in reply to performance of map vs. foreach

Benchmark could have been more informative if perl version, machine load status and such had been given.

Using ikegami's code, perl 5.8.5 (FreeBSD/i386, 4.9-p11) gives on a quite idle machine (386MB RAM, 700MHz CPU, FreeBSD 4.10-p5) ...

           Rate Map-like      Map  Foreach
Map-like 8.69/s       --      -2%     -29%
Map      8.90/s       2%       --     -27%
Foreach  12.3/s      41%      38%       --

... which obviously confirms that overall foreach is indeed faster than map.

Replies are listed 'Best First'.
Re^2: performance of map vs. foreach
by ikegami (Patriarch) on Dec 16, 2004 at 18:03 UTC
    ActivePerl 5.8.0 or 5.8.1, WinXP, P4/2.66GHz, 1GB RAM, idle machine