From f675f55fe8598a49eea316171f080bf607df1e12 Mon Sep 17 00:00:00 2001 From: Alies Lapatsin <5278175+alies-dev@users.noreply.github.com> Date: Mon, 9 Nov 2026 19:32:25 +0100 Subject: [PATCH] feat(check): report boot, analysis and total time in Server-Timing Shows in DevTools how much of a slow /check response is PHP startup, Psalm, or neither (network, server queue). --- views/check.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/views/check.php b/views/check.php index fdeaf3c..0265339 100644 --- a/views/check.php +++ b/views/check.php @@ -59,10 +59,24 @@ exit; } +$analysis_start = microtime(true); + // every homepage view analyzes the example, so its results come from a cache $results = $file_contents === HomepageExample::CODE ? HomepageExample::results($settings, $fix_file, $php_version, $error_level) : OnlineChecker::getResults($file_contents, $settings, $fix_file, $php_version, $error_level); +$analysis_end = microtime(true); +$body = json_encode($results, JSON_HEX_TAG | JSON_HEX_AMP); + +// durations only, in ms: how much of a slow response is PHP startup, Psalm, or neither (network, server queue) +$request_start = $_SERVER['REQUEST_TIME_FLOAT'] ?? $analysis_start; +header(sprintf( + 'Server-Timing: boot;dur=%.1f, analysis;dur=%.1f, total;dur=%.1f', + ($analysis_start - $request_start) * 1000.0, + ($analysis_end - $analysis_start) * 1000.0, + (microtime(true) - $request_start) * 1000.0 +)); + http_response_code(200); -echo json_encode($results, JSON_HEX_TAG | JSON_HEX_AMP); +echo $body;