Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions packages/test-utils/src/perf-test-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface PerfSnapshot {
eventLoopDelayP95Ms: number;
eventLoopDelayP99Ms: number;
eventLoopDelayMaxMs: number;
heapUsed?: number;
}

/**
Expand Down Expand Up @@ -161,6 +162,7 @@ export class PerfTestHarness {
eventLoopDelayP95Ms: 0,
eventLoopDelayP99Ms: 0,
eventLoopDelayMaxMs: 0,
heapUsed: process.memoryUsage().heapUsed,
Comment thread
sripasg marked this conversation as resolved.
Resolved
};
}

Expand Down Expand Up @@ -374,6 +376,11 @@ export class PerfTestHarness {
lines.push(
` CPU: ${cpuMs} (user: ${formatUs(result.median.cpuUserUs)}, system: ${formatUs(result.median.cpuSystemUs)})`,
);
if (result.median.heapUsed !== undefined) {
lines.push(
` Memory: ${(result.median.heapUsed / (1024 * 1024)).toFixed(1)} MB`,
Comment thread
sripasg marked this conversation as resolved.
Resolved
);
}

if (result.median.eventLoopDelayP99Ms > 0) {
lines.push(
Expand Down
28 changes: 17 additions & 11 deletions perf-tests/baselines.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
{
"version": 1,
"updatedAt": "2026-04-08T18:51:29.839Z",
"updatedAt": "2026-04-08T22:28:27.448Z",
"scenarios": {
"cold-startup-time": {
"wallClockMs": 1333.4230420000004,
"cpuTotalUs": 1711,
"wallClockMs": 927.553249999999,
"cpuTotalUs": 1470,
"eventLoopDelayP99Ms": 0,
"timestamp": "2026-04-08T18:50:58.124Z"
"timestamp": "2026-04-08T22:27:54.871Z"
},
"idle-cpu-usage": {
"wallClockMs": 5001.926125,
"cpuTotalUs": 128518,
"eventLoopDelayP99Ms": 12.705791,
"timestamp": "2026-04-08T18:51:23.938Z"
"wallClockMs": 5000.460750000002,
"cpuTotalUs": 12157,
"eventLoopDelayP99Ms": 11.108351,
"timestamp": "2026-04-08T22:28:19.098Z"
},
"skill-loading-time": {
"wallClockMs": 1372.4463749999995,
"cpuTotalUs": 1550,
"wallClockMs": 930.0920409999962,
Comment thread
sripasg marked this conversation as resolved.
Resolved
"cpuTotalUs": 1323,
"eventLoopDelayP99Ms": 0,
"timestamp": "2026-04-08T18:51:29.839Z"
"timestamp": "2026-04-08T22:28:23.290Z"
},
"high-volume-shell-output": {
"wallClockMs": 936.6500410000008,
"cpuTotalUs": 1352,
"eventLoopDelayP99Ms": 0,
Comment thread
sripasg marked this conversation as resolved.
Resolved
"timestamp": "2026-04-08T22:28:27.448Z"
}
}
}
30 changes: 30 additions & 0 deletions perf-tests/perf-usage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,34 @@ describe('CPU Performance Tests', () => {
harness.assertWithinBaseline(result);
}
});

it('high-volume-shell-output: handles large output efficiently', async () => {
const result = await harness.runScenario(
'high-volume-shell-output',
async () => {
const rig = new TestRig();
try {
rig.setup('perf-high-volume-output', {
fakeResponsesPath: join(__dirname, 'perf.high-volume.responses'),
});

return await harness.measure('high-volume-output', async () => {
await rig.run({
args: ['Generate 1M lines of output'],
timeout: 120000,
env: { GEMINI_API_KEY: 'fake-perf-test-key' },
});
});
Comment thread
sripasg marked this conversation as resolved.
Resolved
} finally {
await rig.cleanup();
}
},
);

if (UPDATE_BASELINES) {
harness.updateScenarioBaseline(result);
} else {
harness.assertWithinBaseline(result);
}
});
});
3 changes: 3 additions & 0 deletions perf-tests/perf.high-volume.responses
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"method":"generateContent","response":{"candidates":[{"content":{"parts":[{"text":"0"}],"role":"model"},"finishReason":"STOP","index":0}]}}
{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I will run a shell command to generate a lot of output."}],"role":"model"},"finishReason":"STOP","index":0}]}]}
{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"run_shell_command","args":{"command":"yes | head -n 1000000"}}}],"role":"model"},"finishReason":"STOP","index":0}]}]}
Loading