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 vs. foreach that is causing your
>> difference. I think for your benchmark to be accurate you are going to
>> have to control the actions taken in the loop, otherwise they affect the
>> accuracy of your benchmark.
> 
> 
> mm this may be true, but realistically, that is how I'd write them in
> code I actually use -- so it behooves me to test them the way I'd
> normally be using them.. not under artificial circumstances in ways I
> normally wouldn't write code.
> 
> I see what you're saying and it makes sense, but in this instance I'm
> more interested in seeing the results of the idiomatic expression of the
> end result. :)
> 

Right, I was just being strict about your wording. You declared that the
foreach was faster than map, but strictly speaking it should have been
"the way I used foreach was faster than the way I used map", which I
wouldn't have argued with. And I am only being that strict because this
is an open, archived forum where there are plenty of people that
wouldn't have recognized the difference and may have taken you as
strictly as I did on purpose, just because they didn't know better.

As far as I am concerned write your code however you wish, make it the
fastest to read...

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to