PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_PERSISTENT => true, PDO::ATTR_EMULATE_PREPARES => false, ], ); $result = match ($operation) { 'account' => benchmarkAccount($pdo, $accountId), 'activity' => benchmarkActivity($pdo, (string) ($_GET['region'] ?? 'north-america')), 'touch' => benchmarkTouch($pdo, $accountId), 'health' => ['status' => 'ok'], default => throw new RuntimeException('Unknown benchmark operation.'), }; http_response_code(200); echo json_encode([ 'operation' => $operation, 'duration_ms' => round((hrtime(true) - $startedAt) / 1_000_000, 3), 'result' => $result, ], JSON_THROW_ON_ERROR); } catch (Throwable $exception) { http_response_code(500); echo json_encode([ 'operation' => $operation, 'error' => $exception->getMessage(), ], JSON_THROW_ON_ERROR); }