LuaSandbox::getProfilerFunctionReport
(PECL luasandbox >= 1.1.0)
LuaSandbox::getProfilerFunctionReport — Fetch profiler data
Parameters
units
-
Measurement unit constant.
Return Values
Returns profiler measurements, sorted in descending order, as an associative
array. Keys are the Lua function names (with source file and line
defined in angle brackets), values are the measurements as int
or float.
Note:
On Windows, this function always returns an empty array. On operating systems that do
not support CLOCK_THREAD_CPUTIME_ID, such as FreeBSD
and Mac OS X, this function will report the elapsed wall-clock time, not
CPU time.
Examples
Example #1 Profiling Lua code
<?php
// create a new LuaSandbox
$sandbox = new LuaSandbox();
// Start the profiler
$sandbox->enableProfiler( 0.01 );
// ... Execute some Lua code here ...
// Fetch the profiler data
$data = $sandbox->getProfilerFunctionReport();
?>