[thelist] efficiency/speed testing php

Jackson Yee jyee at vt.edu
Tue Jul 8 19:56:05 CDT 2003


----- Original Message ----- 
From: "Chris W. Parker" <cparker at swatgear.com>

> What I want to do is test the code I'm writing so that I
> can find bottlenecks and fix them (if possible). I am
> running my scripts on a slow system and I'd like to
> improve the code as much as possible.

There are lots of code snippets floating around the net, but the best 
performance gains have always been seen from my experience in improving the 
algorithm used in the page.  If there's something in your code that's used 90% 
of the time, make that as lean as possible.

For general PHP code, I'd suggest

* Limit the number of database queries made as much as possible.  Database 
connections can have a dramatic impact on page processing speed.

* Don't include() unnecessary code in all files.

* Using PHP Accelerator (*huge* difference)

* Avoiding PHP scripts and using static HTML when possible.  Most pages on a 
website actually don't need to be dynamic, and can be implemented in regular 
HTML by capturing the output from a PHP script just fine.  If only an image or 
other external entity on a page needs to change, implement that in script such 
as <img src="/images/rotate.php" /> and leave the regular page alone.

* Using microtime() to test various algorithms out.

There can be a lot more tips, but these are the basic ones which I can think 
of.

Regards,
Jackson Yee
jyee at vt.edu



More information about the thelist mailing list