9 public static function suite( $className ) {
14 return parent::getTestModules() + [
15 'SandboxTests' => __DIR__ .
'/SandboxTests.lua',
21 $this->markTestSkipped(
"getrusage is not available" );
26 $pp = $parser->getPreprocessor();
27 $frame = $pp->newFrame();
29 $parser->setHook(
'scribuntodelay',
function () {
35 }
while (
$t < $endTime );
39 $this->extraModules[
'Module:TestArgumentParsingTime'] =
'
41 f = function ( frame )
44 f2 = function ( frame )
45 return frame:preprocess( "{{#invoke:TestArgumentParsingTime|f|}}" )
47 f3 = function ( frame )
48 return frame:preprocess( "{{#invoke:TestArgumentParsingTime|f|<scribuntodelay/>}}" )
59 $u0 =
$engine->getInterpreter()->getCPUUsage();
63 '{{#invoke:TestArgumentParsingTime|f|<scribuntodelay/>}}'
66 $threshold = $this->
getRuTime() - $uTimeBefore - $delta;
67 $this->assertLessThan( $threshold,
$engine->getInterpreter()->getCPUUsage() - $u0,
68 'Argument access time was not counted'
72 $u0 =
$engine->getInterpreter()->getCPUUsage();
75 '{{#invoke:TestArgumentParsingTime|f2|<scribuntodelay/>}}'
78 $threshold = $this->
getRuTime() - $uTimeBefore - $delta;
79 $this->assertLessThan( $threshold,
$engine->getInterpreter()->getCPUUsage() - $u0,
80 'Unused arguments not counted in preprocess'
84 $u0 =
$engine->getInterpreter()->getCPUUsage();
87 '{{#invoke:TestArgumentParsingTime|f3}}'
90 $threshold = $this->
getRuTime() - $uTimeBefore - $delta;
92 $this->assertGreaterThan( $threshold,
$engine->getInterpreter()->getCPUUsage() - $u0,
93 'Recursive argument access time was counted'
99 return $ru[
'ru_utime.tv_sec'] + $ru[
'ru_utime.tv_usec'] / 1e6 +
100 $ru[
'ru_stime.tv_sec'] + $ru[
'ru_stime.tv_usec'] / 1e6;