viernes, 29 de febrero de 2008

Practical (and impractical) PHP Optimizations

I've been seeing a lot of articles popping up lately about PHP Optimizations, particularly within the code (rather than the configuration, server, caching, etc) that I have some nitpicks with.

My position remains the same: Unless your code is running incredibly slow, you've found every single bug you can possibly find without having nightmares about unit tests, or an optimization that makes more than a 10% improvement in speed (factoring in your margin of error,) don't bother. That said, let's down to brass tacks.

Each test is run 1000 times and the execution time is averaged over two different ways of achieving the same results. Execution times are rounded to millionths of a second, and taken using microtime. The server is running Ubuntu 7.10 server with PHP 5.2.3-1 and Apache 2, and will not have anything else open to keep the margin of error as low as possible. To be on the safe side, my margin of error (between doing this for years, and my guesstimate after running countless hours of benchmarks) is about 15% +/-.

(more...)

No hay comentarios: