Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^5: Best way to sum an array?

by hippo (Bishop)
on May 25, 2017 at 16:08 UTC ( [id://1191228]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Best way to sum an array?
in thread Best way to sum an array?

Darned if I can find any significant difference for as few as 3 numbers to add. Pretty consistently 4-5/100ths for both to start perl, count the numbers and return to the prompt

Interesting. Using precisely your 2 scripts, I see the withListUtil.pl taking about 60-70% longer.

$ time for i in {1..1000}; do perl withListUtil.pl > /dev/null; done real 0m6.512s user 0m3.820s sys 0m2.867s $ time for i in {1..1000}; do perl withoutListUtil.pl > /dev/null; don +e real 0m3.880s user 0m1.538s sys 0m2.497s

For the record, this is perl v5.20.3 with List::Util v1.42 on 64-bit Linux.

Replies are listed 'Best First'.
Re^6: Best way to sum an array?
by BrowserUk (Patriarch) on May 26, 2017 at 07:03 UTC

    I guess my point (in my reply to you), is that if the cost of loading a (small, mostly precompiled binary) module is a significant factor in the runtime of a given application, then Perl is probably the wrong choice of language.

    But really, the "why wouldn't you" in the post to which you replied was a throw away comment rather than a scientific pronouncement; you seem to be making an issue of a non-issue.

    S'funny, I'm normally on the other side of this discussion. I rarely advocate the use of a module over one line of perl; but in this case, the benefits equation really does bias one way in 99% of cases.

    But I guess I'll go back to lurking...


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
    In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-18 05:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found