Yolk Profiler
, (*1)
A simple profiling library for benchmarking code execution speed, memory usage and database queries., (*2)
Requirements
This library requires only PHP 5.4 or later and the Yolk Contracts package (gamernetwork/yolk-contracts)., (*3)
Installation
It is installable and autoloadable via Composer as gamer-network/yolk-profiler., (*4)
Alternatively, download a release or clone this repository, and add the \yolk\profiler namespace to an autoloader., (*5)
License
Yolk Profiler is open-sourced software licensed under the MIT license, (*6)
Quick Start
use yolk\profiler\Profiler;
$profiler = new Profiler();
$profiler->start('Op 1');
lengthyOperation1();
$profiler->stop('Op 1');
$profiler->start('Op 2');
lengthyOperation2();
$profiler->stop('Op 2');
// profile a query
$profiler->start('Query1');
doDatabaseQuery($sql, $params);
$profiler->stop('Query1');
$profiler->query($sql, $params, $profiler->getElapsed('Query1'));
// add some additional info
$profiler->meta('get', $_GET);
$profiler->meta('post', $_POST);
$profiler->stop();
// get a report
print_r(
$profiler->getData()
);
Profiler Method Reference
reset( $time = null, $memory = null );, (*7)
start( $timer, $reset = false, $time = null );, (*8)
stop( $timer = null );, (*9)
isRunning( $timer = '' );, (*10)
getElapsed( $timer = '' );, (*11)
mark( $name = '' );, (*12)
query( $query, $parameters, $duration );, (*13)
meta( $key, $value );, (*14)
getQueries();, (*15)
getData();, (*16)