Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Performance improvement by using $_ instead of named variables

by QM (Parson)
on Nov 04, 2013 at 12:25 UTC ( [id://1061120]=note: print w/replies, xml ) Need Help??


in reply to Re: Performance improvement by using $_ instead of named variables
in thread Performance improvement by using $_ instead of named variables

Processing is fast. I/O is slow.

Whenever someone asks me to look at their code for speedups, we often get into this discussion. For the more obstinate, I often suggest making a "do-nothing" version of their program that just reads in (files or whatever) and writes it back out again. Run this on a sample/benchmark input. We can then argue about Big-Oh numbers, and how this do-nothing version's input/output volume compares with a real example.

Results are often along these lines: "The Do Nothing version took 5 minutes to read a bazillion records and write them out again. The real program is taking an extra 5 seconds on top of that (on average). If you really need a speedup, use faster storage media."

I've always found Perl's IO to be very fast, roughly comparable to something written in C. To check, compare a "passthrough" script like:

perl -pe '' blah.in >/dev/null

-QM
--
Quantum Mechanics: The dreams stuff is made of

  • Comment on Re^2: Performance improvement by using $_ instead of named variables
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-26 01:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found