PHP-Profiler is a project mainly written in PHP and JAVASCRIPT, it's free.
A quick, easy to use, profiler for PHP applications
Version 2
by Steven Surowiec [email protected]
PHP Profiler is a fork of PHP Quick Profiler by Ryan Campbell of Particletree
Setup is very easy and straight-forward. There are five primary steps that need to be done.
Setting up PHP Profiler is quite simple. Below is a short code sample of the latest version.
$profiler = new Profiler_Profiler();
Profiler_Console::logSpeed('Start Sample run');
Profiler_Console::logMemory($object);
Profiler_Console::logSpeed('End Sample run');
$profiler->display();
Exceptions can also be logged:
try {
// Some code goes here
}
catch (Exception $e) {
Profiler_Console::logError($e, $e->getMessage());
}
Database queries can be logged as well:
Profiler_Console::logQuery($sql); // Starts timer for query
$res = mysql_query($sql);
Profiler_Console::logQuery($sql); // Ends timer for query
Using a custom callback to explain queries for console
$profiler = Profiler_Profiler(array('query_explain_callback' => array('My_Class', 'someMethod')));
Profiler_Console::logQuery($sql); // Starts timer for query
$res = mysql_query($sql);
Profiler_Console::logQuery($sql); // Ends timer for query
$profiler->display();
class My_Class {
// $sql gets passed in with 'EXPLAIN' already added.
public static function someMethod($sql) {
$res = mysql_query($sql);
return mysql_fetch_assoc($res);
}
}
PHP Profiler lets you pass in some configuration options to help allow it to suit your own needs.
For additional documentation and code samples see the wiki.
Below are some of the features of PHP Profiler
Using PHP Profiler on your site? Let me know! If you don't want to be featured here just say so, but I still like knowing how people are using PHP Profiler so send me a message or an email and let me know.