<?php
declare(strict_types=1);

/**
 * بنچمارک bootstrap standalone
 * php run-standalone-bench.php
 */
define('ACC_BASE_PATH', __DIR__);

$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI']    = getenv('ACC_BENCH_PATH') ?: '/acc-engine/api.php/acc/v1/accounting/events';
$_SERVER['SCRIPT_NAME']    = '/acc-engine/api.php';

$t0 = microtime(true);
require __DIR__ . '/standalone/bootstrap.php';
$bootstrapMs = round((microtime(true) - $t0) * 1000, 2);

echo json_encode([
    'success' => true,
    'path'    => $requestPathEarly ?? null,
    'controllers_loaded' => count($loadedControllerFiles ?? []),
    'routes_indexed'     => !empty($GLOBALS['acc_route_index']),
    'route_buckets'      => isset($GLOBALS['acc_route_index']['GET'])
        ? count($GLOBALS['acc_route_index']['GET'])
        : 0,
    'bootstrap_ms'       => $bootstrapMs,
    'lazy_mode'          => !acc_should_load_all_controllers(),
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
