Speeding up Your Perl Programs

How fast does your Perl run? I hope that, most of the time, the answer is "fast enough". But sometimes it may not be. How do we speed up a Perl program? How do we know what's making it unacceptably slow?

The first rule of speed optimization is "don't". Certainly, don't write things that waste time, but first aim for clarity and maintainability. With today's processor speeds far exceeding the "supercomputers" of yesterday, sometimes that's "fast enough".

But how do we know whether something is "fast enough"? The first easy cut is just to check total run time. That's usually as simple as putting "time" in front of your program invocation, and looking at the result (which may vary depending on your operating system and choice of shell).


Post new comment

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h1> <quote> <img>
  • Lines and paragraphs break automatically.

More information about formatting options