Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"generate-docs": "npm run build && node --experimental-strip-types scripts/generate-docs.ts",
"start": "npm run build && node build/src/index.js",
"start-debug": "DEBUG=mcp:* DEBUG_COLORS=false npm run build && node build/src/index.js",
"test": "npm run build && npx puppeteer browsers install chrome@latest && node --test-reporter spec --test-force-exit --test 'build/tests/**/*.test.js'",
"test:only": "npm run build && npx puppeteer browsers install chrome@latest && node --test-reporter spec --test-force-exit --test --test-only 'build/tests/**/*.test.js'",
"test:only:no-build": "npx puppeteer browsers install chrome@latest && node --test-reporter spec --test-force-exit --test --test-only 'build/tests/**/*.test.js'",
"test": "npm run build && node --test-reporter spec --test-force-exit --test 'build/tests/**/*.test.js'",
"test:only": "npm run build && node --test-reporter spec --test-force-exit --test --test-only 'build/tests/**/*.test.js'",
"test:only:no-build": "node --test-reporter spec --test-force-exit --test --test-only 'build/tests/**/*.test.js'",
"prepare": "node --experimental-strip-types scripts/prepare.ts"
},
"files": [
Expand Down
38 changes: 33 additions & 5 deletions src/tools/performance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,31 @@ export const startTrace = defineTool({
});
}

// TODO(jacktfranklin): determine the exact list of categories and
// align with DevTools
await page.tracing.start();
// This panel may be opened with trace data recorded in other tools.
// Keep in sync with the categories arrays in:
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/panels/timeline/TimelineController.ts
// https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/gather/gatherers/trace.js
const categories = [
'-*',
'blink.console',
'blink.user_timing',
'devtools.timeline',
'disabled-by-default-devtools.screenshot',
'disabled-by-default-devtools.timeline',
'disabled-by-default-devtools.timeline.invalidationTracking',
'disabled-by-default-devtools.timeline.frame',
'disabled-by-default-devtools.timeline.stack',
'disabled-by-default-v8.cpu_profiler',
'disabled-by-default-v8.cpu_profiler.hires',
'latencyInfo',
'loading',
'disabled-by-default-lighthouse',
'v8.execute',
'v8',
];
await page.tracing.start({
categories,
});

if (request.params.reload) {
await page.goto(pageUrlForTracing, {
Expand Down Expand Up @@ -98,8 +120,14 @@ async function stopTracingAndAppendOutput(
response.appendResponseLine('The performance trace has been stopped.');
if (result) {
const insightText = insightOutput(result);
response.appendResponseLine('Insights with performance opportunities:');
response.appendResponseLine(insightText);
if (insightText) {
response.appendResponseLine('Insights with performance opportunities:');
response.appendResponseLine(insightText);
} else {
response.appendResponseLine(
'No insights has been found. The performance looks good!',
);
}
}
} catch (e) {
logger(
Expand Down
Loading