PFSenseDevWiki : ProfilingPHP

PfSenseDevHome :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register
Most recent edit on 2007-12-26 03:04:47 by ChrisBuechler

Additions:
Fetch http://pfsense.org/~cmb/tools/profiling/Timer.php.txt to /etc/inc/Timer.php

Deletions:
Fetch http://pfsense.org/~cmb/tools/Timer.php.txt to /etc/inc/Timer.php



Edited on 2007-12-26 03:04:03 by ChrisBuechler

Additions:
Fetch http://pfsense.org/~cmb/tools/Timer.php.txt to /etc/inc/Timer.php

Deletions:
Fetch http://pfsense.org/~cmb/tools/Timer.phps to /etc/inc/Timer.php



Edited on 2007-12-26 03:02:50 by ChrisBuechler

Additions:
Fetch http://pfsense.org/~cmb/tools/Timer.phps to /etc/inc/Timer.php

Deletions:
Fetch http://pfsense.org/~cmb/tools/Timer.php to /etc/inc



Edited on 2007-12-25 21:29:06 by ChrisBuechler

Additions:
marker times are the time since the previous marker point. i.e. it took 6.08 seconds to get from marker9 to marker10.



Oldest known version of this page was edited on 2007-12-25 21:26:43 by ChrisBuechler []
Page view:

Profiling PHP


PEAR's Benchmark_Timer can be used to profile PHP code. To use:

Fetch http://pfsense.org/~cmb/tools/Timer.php to /etc/inc

Add code like the following to the page you wish to profile.

require_once("Timer.php");
$timer = new Benchmark_Timer;

$timer->start();


Then add markers to time execution between specific points in the code.

$timer->setMarker('marker1');


When finished, the following code stops the timer and logs the time of each marker and the total time to the System log.

$timer->stop();
$profiling = $timer->getProfiling();
foreach($profiling as $time) {
	    log_error("profiling: {$time['name']} : {$time['diff']}");
}
log_error("Total time:  {$time['total']}");


Example Usage


http://pfsense.org/~cmb/tools/profiling/interfaces_vlan_edit.php.txt shows Benchmark_Timer in use.

this is the resultant log file
http://pfsense.org/~cmb/tools/profiling/profiling_logs.png
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.3
Page was generated in 0.0685 seconds