Files
orca/tests/e2e/terminal-perf-presentation.ts
T
Neil 35fe67b610 fix(perf): measure terminal latency with presented CI frames (#22096)
* fix(perf): present benchmark frames only on isolated CI display

* fix(perf): wait for the benchmark page before presenting its window

* docs(perf): record full scale pass with unchanged latency budgets

* test(perf): document and verify the isolated display exception
2026-09-21 16:03:40 -07:00

41 lines
1.3 KiB
TypeScript

import type { ElectronApplication, TestInfo } from '@stablyai/playwright-test'
export function shouldPresentTerminalPerfWindow(
env: Readonly<Record<string, string | undefined>> = process.env,
platform: string = process.platform
): boolean {
if (env.ORCA_E2E_TERMINAL_PERF_XVFB !== '1') {
return false
}
if (
platform !== 'linux' ||
env.GITHUB_ACTIONS !== 'true' ||
env.RUNNER_ENVIRONMENT !== 'github-hosted' ||
!env.DISPLAY
) {
throw new Error('Terminal perf presentation requires an isolated GitHub Actions Xvfb display')
}
return true
}
export async function presentTerminalPerfWindow(
electronApp: Pick<ElectronApplication, 'evaluate'>,
testInfo: Pick<TestInfo, 'annotations'>
): Promise<void> {
if (!shouldPresentTerminalPerfWindow()) {
return
}
// An unpresented Linux window triggers Chromium's one-second undrawn-frame throttle.
const visible = await electronApp.evaluate(({ BrowserWindow }) => {
const windows = BrowserWindow.getAllWindows()
for (const window of windows) {
window.showInactive()
}
return windows.length > 0 && windows.every((window) => window.isVisible())
})
if (!visible) {
throw new Error('Terminal perf window was not presented on the isolated display')
}
testInfo.annotations.push({ type: 'terminal-perf-presentation', description: 'isolated-xvfb' })
}