John W. Krahn wrote:
Scott R. Godin wrote:
Interesting .. I would have thought that map would be faster, but it
appears that foreach is, in this instance. curious.. :)
[snip]
To be equivalent the foreach sub should use assignment instead of
postincrement (which is also faster.)
Wiggins d'Anconia wrote:
Your benchmark isn't controlled. In the first instance you are doing a
++ on what amounts to a scalar getting autovivified, in the second
instance you are assigning a pair of values to a list then autovivifying
it. It isn't necessarily the map vs. foreach that is
Scott R. Godin wrote:
Wiggins d'Anconia wrote:
Your benchmark isn't controlled. In the first instance you are doing a
++ on what amounts to a scalar getting autovivified, in the second
instance you are assigning a pair of values to a list then autovivifying
it. It isn't necessarily the map
Interesting .. I would have thought that map would be faster, but it appears
that foreach is, in this instance. curious.. :)
4:52pm {193} localhost:/home/webadmin/$ perl bench.pl
Benchmark: running Foreach, Map for at least 5 CPU seconds...
Foreach: 9 wallclock secs
( 5.24 usr +
Scott R. Godin wrote:
Interesting .. I would have thought that map would be faster, but it
appears that foreach is, in this instance. curious.. :)
4:52pm {193} localhost:/home/webadmin/$ perl bench.pl
Benchmark: running Foreach, Map for at least 5 CPU seconds...
Foreach: 9 wallclock
And don't run the two test too soon after eachother, your operating
system will cache some data. Also run all the tests multiple times.
Wijnand
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
Scott R. Godin wrote:
Interesting .. I would have thought that map would be faster, but it
appears that foreach is, in this instance. curious.. :)
4:52pm {193} localhost:/home/webadmin/$ perl bench.pl
Benchmark: running Foreach, Map for at least 5 CPU seconds...
Foreach: 9 wallclock