mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 16:02:32 +00:00
* test: reproduce accumulated-workspace typing latency through real PTYs * test: make the bench harness self-checks falsifiable Review found four assertions that could not fail and one fixture gap: - `missingPtyArrivalCount`/`missingEchoCount` were hardcoded `0` and `validateExpectedSeqs` throws before them, so every assertion on them was vacuous and every report read `0`. The throw is the real guard and is already covered; drop the vestigial fields. - An absent status controller returned an all-zero result, which satisfied its own accepted-equals-generated equality. Assert presence first. - The byte-pacing control had only an upper bound, so a generator emitting no stream bytes passed. Add the lower bound. - `lineageEvery: 1` built zero lineage: no ordinal satisfies `% 1 === 1`. Offset the interval and cover the densest setting. - The documented control command never set ORCA_TYPING_BENCH, so it skipped instead of running.
29 lines
843 B
TypeScript
29 lines
843 B
TypeScript
import type { Page } from '@stablyai/playwright-test'
|
|
import { mkdirSync, writeFileSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
|
|
export async function withTypingRendererCpuProfile<T>(
|
|
page: Page,
|
|
outputPath: string | undefined,
|
|
measure: () => Promise<T>
|
|
): Promise<T> {
|
|
if (!outputPath) {
|
|
return measure()
|
|
}
|
|
const session = await page.context().newCDPSession(page)
|
|
try {
|
|
await session.send('Profiler.enable')
|
|
await session.send('Profiler.setSamplingInterval', { interval: 1000 })
|
|
await session.send('Profiler.start')
|
|
try {
|
|
return await measure()
|
|
} finally {
|
|
const { profile } = await session.send('Profiler.stop')
|
|
mkdirSync(path.dirname(outputPath), { recursive: true })
|
|
writeFileSync(outputPath, JSON.stringify(profile))
|
|
}
|
|
} finally {
|
|
await session.detach()
|
|
}
|
|
}
|