Improving your PHP code What is application profiling?

Profiling is the process of breaking down all the functions called in an application and, for each of them, analyzing its execution time and how many times it was called.

These good sheets are taken from the book “Performances PHP”, by
Julien Pauli, Cyril Pierre de Geyer and Guillaume Plessis, published by
Eyrolles. Eyrolles

This is an important step in improving performance: profiling targets very precisely the slow functions of an application, in order to optimize them or to create a cache system so that they are less solicited.

Principle to remember

The principle is quite simple. A PHP extension measures the time that PHP has spent in each function during the processing of an HTTP request.

1 The profiler is activated (via a PHP extension).
2 We launch an HTTP request to the page to be tested.
3 The profiler stores the various low-level actions of PHP in the form of “traces”.
4 The measurements that have been made are then processed.

Software transforms these traces into visual representations that help to identify any performance problems encountered during the processing of the request.

The best known PHP extension for profiling a script is called Xdebug but
other profilers exist: we will introduce you to XhProf, which offers two advantages.

It creates traces that are also lighter than those of Xdebug.

The most successful software for visual representation of traces is KcacheGrind

Leave a Comment