CascadiaPHP 2024


(PECL luasandbox >= 1.1.0)

LuaSandbox::getProfilerFunctionReportFetch profiler data


public LuaSandbox::getProfilerFunctionReport(int $units = LuaSandbox::SECONDS): array

For a profiling instance previously started by LuaSandbox::enableProfiler(), get a report of the cost of each function.

The measurement unit used for the cost is determined by the $units parameter:


Measure in number of samples.


Measure in seconds of CPU time.


Measure percentage of CPU time.

Liste de paramètres


Measurement unit constant.

Valeurs de retour

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.


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.


Exemple #1 Profiling Lua code


// 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();


add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top