Benchmark with care

I saw this site recently: was constructed as a way to open people’s eyes to the fact that not every PHP code snippet will run at the same speed

This is useless! Or let me reformulate: this is misleading! For one, it uses microtime to do the benchmark, which measures physical time as opposed to CPU time, meaning that as the load varies on the server, the results will change (since they are re-done at each page refresh).

Also, source code readability is far, far more important than such micro benchmarks. Usually there is more than one way to do it in programming language so that programmers can choose the representation which is closest to the semantic meaning that they had in mind (thus minimizing the effort needed to translate it into code and hence minimizing the error rate).

As I said earlier, the best optimization technique is to know the functionality available to you out-of-the-box as best as possible and avoid looping through data in PHP.

Leave a Reply

Your email address will not be published. Required fields are marked *