mirror of
https://github.com/LamGC/wp-asciiplayer.git
synced 2026-11-27 05:05:50 +00:00
test: add isolated resource-budget experiment experiment/php/measure.php
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
// One fresh CLI process per measurement; fixtures generated by the controller.
|
||||
$root=$argv[1]; $input=$argv[2]; $mode=$argv[3];
|
||||
define('ABSPATH', '/');
|
||||
require $root.'/includes/uploads.php';
|
||||
require __DIR__.'/preflight.php';
|
||||
$text=file_get_contents($input);
|
||||
if ($text === false || strlen($text)>2097152) throw new RuntimeException('Unexpected fixture size.');
|
||||
$before=memory_get_usage(false); $before_real=memory_get_usage(true);
|
||||
$start=microtime(true); $decoded=false; $gate=null;
|
||||
if ($mode==='gated') $gate=preflight_budget($text);
|
||||
if ($gate===null || $gate['ok']) {$valid=\LamGC\Asciiplayer\is_cast_v1($text);$decoded=true;}
|
||||
else $valid=false;
|
||||
echo json_encode(array('php'=>PHP_VERSION,'sapi'=>PHP_SAPI,'int_size'=>PHP_INT_SIZE,'mode'=>$mode,'input_bytes'=>strlen($text),'memory_limit'=>ini_get('memory_limit'),'before_bytes'=>$before,'before_real_bytes'=>$before_real,'peak_bytes'=>memory_get_peak_usage(false),'peak_real_bytes'=>memory_get_peak_usage(true),'elapsed_ms'=>round((microtime(true)-$start)*1000,3),'decoded'=>$decoded,'valid'=>$valid,'gate'=>$gate),JSON_THROW_ON_ERROR)."\n";
|
||||
Reference in New Issue
Block a user