pilot_perf
Measure page load performance metrics including DNS, TCP, SSL, TTFB, and DOM parsing to diagnose slow pages and identify bottlenecks.
Instructions
Measure page load performance metrics from the Navigation Timing API. Use when the user wants to diagnose slow page loads, benchmark performance, or identify bottlenecks in DNS lookup, connection, server response, or DOM parsing.
Parameters: (none)
Returns: Table of timing metrics in milliseconds — dns, tcp, ssl, ttfb (time to first byte), download, domParse, domReady, and load.
Errors:
"No navigation timing data available": The page has not completed a navigation or was loaded via non-standard means. Navigate to the page first with pilot_navigate, then reload.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/inspection.ts:212-248 (handler)The handler function for the 'pilot_perf' tool. It uses the Navigation Timing API to measure page load performance metrics (dns, tcp, ssl, ttfb, download, domParse, domReady, load) and returns them as a formatted table.
server.tool( 'pilot_perf', `Measure page load performance metrics from the Navigation Timing API. Use when the user wants to diagnose slow page loads, benchmark performance, or identify bottlenecks in DNS lookup, connection, server response, or DOM parsing. Parameters: (none) Returns: Table of timing metrics in milliseconds — dns, tcp, ssl, ttfb (time to first byte), download, domParse, domReady, and load. Errors: - "No navigation timing data available": The page has not completed a navigation or was loaded via non-standard means. Navigate to the page first with pilot_navigate, then reload.`, {}, async () => { await bm.ensureBrowser(); try { const timings = await bm.getPage().evaluate(() => { const nav = performance.getEntriesByType('navigation')[0] as PerformanceNavigationTiming; if (!nav) return 'No navigation timing data available.'; return { dns: Math.round(nav.domainLookupEnd - nav.domainLookupStart), tcp: Math.round(nav.connectEnd - nav.connectStart), ssl: Math.round(nav.secureConnectionStart > 0 ? nav.connectEnd - nav.secureConnectionStart : 0), ttfb: Math.round(nav.responseStart - nav.requestStart), download: Math.round(nav.responseEnd - nav.responseStart), domParse: Math.round(nav.domInteractive - nav.responseEnd), domReady: Math.round(nav.domContentLoadedEventEnd - nav.startTime), load: Math.round(nav.loadEventEnd - nav.startTime), }; }); if (typeof timings === 'string') return { content: [{ type: 'text' as const, text: timings }] }; const text = Object.entries(timings).map(([k, v]) => `${k.padEnd(12)} ${v}ms`).join('\n'); return { content: [{ type: 'text' as const, text }] }; } catch (err) { return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true }; } } ); - src/tools/register.ts:81-81 (registration)Registration call in registerAllTools: registerInspectionTools(effectiveServer, bm) which registers the pilot_perf tool among other inspection tools.
registerInspectionTools(effectiveServer, bm);