Allow the profiler to be configured or disabled

Because bugs were found in it.

Change-Id: I2737bad8663af3c8afec8a0ea4cca5d0f5b13714
This commit is contained in:
Tim Starling 2012-12-28 10:26:06 +11:00 committed by Gerrit Code Review
parent 6e3c5da6b8
commit 2b4b42288c
2 changed files with 12 additions and 3 deletions

View file

@ -112,6 +112,9 @@ $wgScribuntoEngineConf = array(
'memoryLimit' => 50 * 1024 * 1024,
'cpuLimit' => 7,
// The profiler sample period, or false to disable the profiler
'profilerPeriod' => 0.02,
// Set this to true to allow setfenv() and getfenv() in user code.
// Note that these functions have been removed in Lua 5.2. Scribunto
// does not yet support Lua 5.2, but we expect support will be

View file

@ -79,9 +79,15 @@ class Scribunto_LuaSandboxInterpreter extends Scribunto_LuaInterpreter {
$this->sandbox = new LuaSandbox;
$this->sandbox->setMemoryLimit( $options['memoryLimit'] );
$this->sandbox->setCPULimit( $options['cpuLimit'] );
if ( is_callable( array( $this->sandbox, 'enableProfiler' ) ) ) {
$this->profilerEnabled = true;
$this->sandbox->enableProfiler( 0.002 );
if ( is_callable( array( $this->sandbox, 'enableProfiler' ) ) )
{
if ( !isset( $options['profilerPeriod'] ) ) {
$options['profilerPeriod'] = 0.02;
}
if ( $options['profilerPeriod'] ) {
$this->profilerEnabled = true;
$this->sandbox->enableProfiler( $options['profilerPeriod'] );
}
}
}