
Where you start the clock decides which function looks slow
One workload, two profiling mechanisms. Instrumentation cost 13% and missed the function that was 55% of the request; sampling cost nothing measurable and found it.
Tags
8 posts

One workload, two profiling mechanisms. Instrumentation cost 13% and missed the function that was 55% of the request; sampling cost nothing measurable and found it.

The same function ran at 21.4 ns with no OPcache, 21.6 with OPcache and the optimizer off, and 14.8 with it on. What the passes removed, dumped one at a time.

phpdbg showed thirteen instructions and the optimizer showed nine. Both were right. How to read the notation, and which listing is the one that runs.

The same .= statement took 0.269 ms and 218.836 ms in two loops that differ by one assignment. What a zend_string costs, where literals live, and why implode is not the fix.

Container compilation moves reflection from request time to build time. What that removes, what it costs, and when it matters.

OPcache removes compilation, not execution. The JIT reaches arithmetic-heavy code and little else. Where the remaining time lives.

Microbenchmarks measure exactly what you tell them to, which is rarely what you meant. Method, noise, and the numbers worth reporting.

A request walks from the SAPI to the Zend VM — lexing, compilation to opcodes, the OPcache lookup that skips both, and execution.