Files
orca/config/scripts/preflight-benchmark-command.mjs
T
Neil ac156c0302 perf(ci): overlap Bun typechecking and skip redundant alias scans (#27382)
* perf(ci): skip unnecessary alias scans and compare preflight compilers

* perf(ci): overlap measured Bun typechecking with static checks

* perf(ci): use measured Bun lint runtime and strengthen compiler parity checks
2026-10-10 22:48:25 -07:00

33 lines
1.0 KiB
JavaScript

import { readFileSync } from 'node:fs'
import path from 'node:path'
import { performance } from 'node:perf_hooks'
import { runProcess } from '@orca/process-host'
export async function measurePreflightCommand({
program,
args,
label,
root,
output,
env,
timeoutMs = 240_000
}) {
const resourceFile = path.join(output, `${label}.resources.txt`)
const start = performance.now()
const result = await runProcess({
program: process.platform === 'linux' ? '/usr/bin/time' : program,
args: process.platform === 'linux' ? ['-v', '-o', resourceFile, program, ...args] : args,
cwd: root,
env: { ...env, LC_ALL: 'C' },
timeoutMs,
maxOutputBytes: 8 * 1024 * 1024
})
if (result.outputTruncated) {
throw new Error(`Benchmark output was truncated: ${label}`)
}
const resources = process.platform === 'linux' ? readFileSync(resourceFile, 'utf8') : ''
const peakRssKiB =
Number(resources.match(/Maximum resident set size \(kbytes\): (\d+)/)?.[1]) || null
return { ...result, durationMs: performance.now() - start, peakRssKiB }
}