Profiler Class

The profiler class allows you to add your own profiling information to the profiler. It implements a customized version of PHPQuickProfiler (PQP).

Configure runtime behaviour

The profiler contains a collection of javascript global variables through which you can control the initial state of the profiler.

Example:

	<script type="text/javascript">
		var PQP_SHOWONLOAD = true;
		var PQP_HEIGHT = 'short';
		var PQP_DETAILS = true;
		var PQP_BOTTOM = true;
	</script>

Class methods

mark($label)

The mark method will add a speed marker to the profiler. This marker will show in the "Load Time" section of the profiler.

Static Yes
Parameters
Param Default Description
$label required A text label to describe the marker to be set.
Returns void
Example
Profiler::mark('start of this piece of code');

mark_memory($var, $name)

The mark_memory method will add a memory marker to the profiler. If you pass a variable, the memory usage of that variable will be logged. If not, the memory usage at the time of marking will be logged.

Static Yes
Parameters
Param Default Description
$var false The variable whose size has to be logged. If false or not specified, PHP memory usage will be logged.
$name 'Memory Usage' A text label to describe the marker to be set.
Returns void
Example
Profiler::mark_memory($this, 'Controller_Welcome object');

console($text)

The console method will add a log entry to the profiler.

Static Yes
Parameters
Param Default Description
$text required A text to describe the log entry to be set.
Returns void
Example
Profiler::console('start of this piece of code');

app_total()

The app_total method returs an array with two values, the number of microseconds Fuel is running processing the current request, and the number of bytes of memory the process has allocated sofar (excluding PHP internal bootstrap memory used).

Static Yes
Parameters None
Returns array
Example
// might return:
// Array
// (
//     [0] => 0.13538384437561
//     [1] => 253208
// )
print_r(Profiler::app_total());

init()

The init method initializes the profiler state. It will create a profiler instance, and sets up database query profiling.
As long as the profiler is not initialized, all profiler methods apart from app_total() are NOOP's.

Static Yes
Parameters None
Returns void
Example
Profiler::reset();

reset()

The reset method reset the Profiler to its uninitialized state. You will have to call init() again if you want to re-enable the profiler.

Static Yes
Parameters None
Returns void
Example
Profiler::reset();