Files
orca/config/scripts/terminal-perf-report-annotations.mjs
T
1f164daf71 Reduce git trace and branch compare polling churn (#6002)
* fix: bound git trace volume

* fix: reduce branch compare polling churn

* test: add benchmark artifact comparison tooling

* fix: address benchmark and polling review comments

* fix: keep branch compare fresh and harden benchmark reports

Co-authored-by: Orca <help@stably.ai>

* Tighten benchmark annotations and polling cleanup

Co-authored-by: Orca <help@stably.ai>

* Handle missing git status heads in Source Control tests

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Wolfgang Schoenberger <221313372+wolfiesch@users.noreply.github.com>
Co-authored-by: brennanb2025 <brennankbenson@gmail.com>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
2026-06-22 19:13:32 -07:00

54 lines
1.5 KiB
JavaScript

import { readFileSync } from 'node:fs'
export function readJsonReport(path) {
const raw = readFileSync(path, 'utf8')
const start = raw.indexOf('{')
const end = raw.lastIndexOf('}')
if (start === -1 || end <= start) {
throw new Error(`${path}: no JSON object found`)
}
return JSON.parse(raw.slice(start, end + 1))
}
export function parseAnnotationDescription(description) {
const values = {}
for (const part of description.split(/\s+/)) {
const index = part.indexOf('=')
if (index === -1) {
continue
}
values[part.slice(0, index)] = part.slice(index + 1)
}
return values
}
export function collectTerminalPerfRows(report, source, options = {}) {
const { typePrefix = 'opencode-' } = options
const rows = []
const visitSuite = (suite) => {
for (const spec of suite.specs ?? []) {
for (const test of spec.tests ?? []) {
for (const annotation of test.annotations ?? []) {
if (!annotation.type.startsWith(typePrefix)) {
continue
}
rows.push({
...parseAnnotationDescription(annotation.description ?? ''),
// Why: annotation descriptions are artifact-controlled; keep the
// trusted report source and annotation type from being relabeled.
source,
scenario: annotation.type
})
}
}
}
for (const child of suite.suites ?? []) {
visitSuite(child)
}
}
for (const suite of report.suites ?? []) {
visitSuite(suite)
}
return rows
}