diff --git a/Scribunto.php b/Scribunto.php index 9b76f5f7..3c4f267a 100644 --- a/Scribunto.php +++ b/Scribunto.php @@ -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 diff --git a/engines/LuaSandbox/Engine.php b/engines/LuaSandbox/Engine.php index 932f965d..b6e77ce5 100644 --- a/engines/LuaSandbox/Engine.php +++ b/engines/LuaSandbox/Engine.php @@ -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'] ); + } } }