Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: map versus for

by MidLifeXis (Monsignor)
on Aug 04, 2008 at 17:06 UTC ( [id://702123]=note: print w/replies, xml ) Need Help??


in reply to map versus for

I have not done much with perl profiling, but when doing a performance comparison, don't you need to return the same results? It looks like the test_for returns the number of elements in the post-push array, whereas test_map returns the new array, at least if I am reading push correctly.

Update:Note that I am not saying that the results will change much. In fact, here are mine for 60 seconds. test_for2 does a return of the array at the end of the test function.

s/iter for2 map for for2 2.70 -- -1% -1% map 2.68 1% -- -0% for 2.67 1% 0% -- Benchmark: running for, for2, map for at least 60 CPU seconds... for: 61 wallclock secs (61.37 usr + 0.02 sys = 61.39 CPU) @ 0 +.37/s (n=23) for2: 61 wallclock secs (61.37 usr + 0.03 sys = 61.40 CPU) @ 0 +.37/s (n=23) map: 62 wallclock secs (61.48 usr + 0.03 sys = 61.51 CPU) @ 0 +.37/s (n=23)

Update 2: Would some kind monk be willing to comment on if it is sufficient to just define the raw function (as in the OP), or would you also need to have the function return into a context of some sort. In other words, should there be another layer of function call here to force list context to make this a valid comparison?

--MidLifeXis

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://702123]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-23 16:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found