[NCLUG] programming question

Evelyn Mitchell efm at tummy.com
Sun Jul 1 09:36:25 MDT 2001


On Sun, Jul 01, 2001 at 09:17:53AM -0600, mike cullerton wrote:
> folks have mentioned this a couple times. what is meant by profiling?

There are tens of different things, from network latency, to cpu
speed, to disk speed to choice of algorithm... which can affect the
speed of a program. The only way to find out which is the bottleneck
in the thing you're trying to optimize is to profile your application.

There's a good article on profiling and tuning Java on Linux at:
  http://www-106.ibm.com/developerworks/ibm/library/i-tuning/

It will give you an idea of the tools available for figuring out
how long something takes, or how much of something it uses.

It's really important to have a global data on how your program runs
in your environment BEFORE you start changing things. Computer systems
often have tightly coupled dendencies, and optimizing one thing
may actually slow the whole thing down.

PHP doesn't seem to have profiling tools, so if you're tracking
how long your code spends in each routine then you'll have to
instrument it yourself. The usual procedure is to write out
to a log file on when you enter and leave a routine, then
calculate the percentage of the total time in each routine.

Python has a good profiling tool:
  http://www.networkcomputing.com/unixworld/tutorial/005/005.html#Speed

Finally, though it is interesting to discover where the performance
of your application could be improved, it's important to remember
that premature optimization is evil. The goal is to create solutions
to problems, and if you think that tweaking code for performance is
a better thing to do than moving on to solving the next problem, then
you're probably working on hard real time embedded applications, 
not web apps. 

It's really important to remember that programmer attention is the
one thing in short supply anymore. CPU speed, Disk space, network
speed.. all have improved so much that optimizing for them is probably
a waste of your time. Yes, there are corner cases where an app is
just too slow, and needs to be fixed. But in all other cases, you're
probably better off adding new functionality than to be optimizing.

Evelyn



More information about the NCLUG mailing list