Re: odd benchmark result, map vs foreach

2005-08-26 Thread Scott R. Godin
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.)

Re: odd benchmark result, map vs foreach

2005-08-26 Thread Scott R. Godin
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

Re: odd benchmark result, map vs foreach

2005-08-26 Thread Wiggins d'Anconia
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

odd benchmark result, map vs foreach

2005-08-24 Thread Scott R. Godin
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 +

Re: odd benchmark result, map vs foreach

2005-08-24 Thread Wiggins d'Anconia
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

Re: odd benchmark result, map vs foreach

2005-08-24 Thread Wijnand Wiersma
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/

Re: odd benchmark result, map vs foreach

2005-08-24 Thread John W. Krahn
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