mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 16:02:32 +00:00
* perf(renderer): avoid per-second spinner animation events * fix(bench): ensure the Electron runtime before bench:spinners The script launches Electron via Playwright but skipped ensure:electron-runtime, which every other Electron-launching bench script runs first. * docs(renderer): scope spinner pixel-tolerance claim to paused-animation checks --------- Co-authored-by: m4air <m4air@m4airs-MacBook-Air.local> Co-authored-by: pullfrog[bot] <226033991+pullfrog[bot]@users.noreply.github.com>
34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
import { writeFileSync } from 'node:fs'
|
|
|
|
export async function traceIterations(cdp, outputPath, durationMs = 2200) {
|
|
await cdp.send('Tracing.start', {
|
|
categories: 'devtools.timeline',
|
|
transferMode: 'ReturnAsStream'
|
|
})
|
|
await new Promise((resolve) => setTimeout(resolve, durationMs))
|
|
const completion = new Promise((resolve) => cdp.once('Tracing.tracingComplete', resolve))
|
|
await cdp.send('Tracing.end')
|
|
const { stream } = await completion
|
|
let json = ''
|
|
try {
|
|
while (true) {
|
|
const part = await cdp.send('IO.read', { handle: stream })
|
|
json += part.data
|
|
if (part.eof) {
|
|
break
|
|
}
|
|
}
|
|
} finally {
|
|
await cdp.send('IO.close', { handle: stream })
|
|
}
|
|
writeFileSync(outputPath, json)
|
|
const events = JSON.parse(json).traceEvents
|
|
return {
|
|
durationMs,
|
|
iterationEvents: events.filter(
|
|
(event) => event.name === 'EventDispatch' && event.args?.data?.type === 'animationiteration'
|
|
).length,
|
|
styleUpdates: events.filter((event) => event.name === 'UpdateLayoutTree').length
|
|
}
|
|
}
|