Chapter 19. Synthetic Benchmarks: Evaluating Code Blocks and Functions
Chapter 18, “Profiling,” describes benchmarking entire applications. This is useful for doing comparative analysis between Web pages to identify slow pages and for measuring the effects of application tuning. Similar techniques are useful for evaluating the differences such as the following between different code blocks:
Is
while()
faster or slower thanforeach()
for loops?Is
substr()
faster thanstrstr()
for matching characters at the beginning of a string?
You could go online and search the PHP general archives to look for the answers, or you could pick up a book (like this one) for some sage advice on the subject, but neither of these methods is really sufficient. One of PHP’s ...
Get Advanced PHP Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.