PHP Profiler
is a small library that provides profiling functionality. It uses the Chrome debugging protocol that is part of the Chrome DevTools. This means that you can generate .cpuprofile
-compatible files that can then be loaded into Chrome profiles in the developer tools.
- In a console,
php composer.phar require tomzx/profiler
$profiler = new \tomzx\Profiler\StackBasedProfiler();
$profiler->start();
// In your code
$profiler->push('My identifier');
///...
$profiler->pop();
$profile = $profiler->stop();
file_put_contents('test.cpuprofile', json_encode($profile));
The code is licensed under the MIT license. See LICENSE.