X7ROOT File Manager
Current Path:
/opt/alt/tests/alt-php82-pecl-luasandbox_4.1.2-2.el8/tests
opt
/
alt
/
tests
/
alt-php82-pecl-luasandbox_4.1.2-2.el8
/
tests
/
📁
..
📄
LuaSandboxFunction_construct.phpt
(253 B)
📄
array-key-conversion.phpt
(3.11 KB)
📄
call.phpt
(5.1 KB)
📄
callback_exception.phpt
(392 B)
📄
datatypes-unsupported.phpt
(2.78 KB)
📄
datatypes.phpt
(2.43 KB)
📄
dump_loadBinary_call.phpt
(393 B)
📄
errors-at-call-boundaries.phpt
(1.98 KB)
📄
extending-LuaSandbox.phpt
(845 B)
📄
ipairs.phpt
(1.53 KB)
📄
loadString.phpt
(334 B)
📄
lua_catches_php_exception.phpt
(1.34 KB)
📄
pairs.phpt
(3.31 KB)
📄
pcall.phpt
(1.27 KB)
📄
profiler-sorting.phpt
(1.18 KB)
📄
profiler.phpt
(1.54 KB)
📄
reentrant.phpt
(1.1 KB)
📄
xpcall.phpt
(2.6 KB)
Editing: profiler-sorting.phpt
--TEST-- profiler sorting --FILE-- <?php // Note these tests have to busy-loop. Even if Lua had an "os.sleep", it'd just // say "sleep" used all the time. And we can't directly loop on os.clock() here // either, because that would say "clock" used most of the time. $lua = <<<LUA function test1() for i = 0, 1e6 do end end function test2() for i = 0, 4e6 do end end function test3() for i = 0, 2e6 do end end function test() local t = os.clock() + 0.5 while os.clock() < t do test1() test2() test3() end end LUA; $sandbox = new LuaSandbox; $sandbox->loadString( $lua )->call(); $sandbox->enableProfiler( 0.01 ); $sandbox->callFunction( 'test' ); foreach( [ 'samples' => LuaSandbox::SAMPLES, 'seconds' => LuaSandbox::SECONDS, 'percent' => LuaSandbox::PERCENT ] as $name => $stat ) { $result = $sandbox->getProfilerFunctionReport( $stat ); // "clone" and sort $sorted = array_combine( array_keys( $result ), array_values( $result ) ); arsort( $sorted ); if ( $result === $sorted ) { echo "$name: OK\n"; } else { echo "$name: FAIL\n"; var_export( [ 'result' => $result, 'sorted' => $sorted, ] ); } } --EXPECTF-- samples: OK seconds: OK percent: OK
Upload File
Create Folder