MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / runBenchmark

Function runBenchmark

tooling/scripts/perf-runtime-repeat.mjs:235–275  ·  view source on GitHub ↗
(targetName, runIndex, warmTempRoot)

Source from the content-addressed store, hash-verified

233}
234
235function runBenchmark(targetName, runIndex, warmTempRoot) {
236 const script = targetName === 'web' ? 'perf:web-runtime' : 'perf:desktop-runtime'
237 const env = { ...process.env }
238 if (runIndex > 0) {
239 if (targetName === 'web') env.ZEN_PERF_SKIP_WEB_BUILD = '1'
240 else env.ZEN_PERF_SKIP_DESKTOP_BUILD = '1'
241 }
242 if (warmTempRoot) {
243 const prefix = targetEnvPrefix(targetName)
244 env[`ZEN_PERF_${prefix}_TEMP_ROOT`] = warmTempRoot
245 if (runIndex > 0) env[`ZEN_PERF_${prefix}_SKIP_SEED`] = '1'
246 }
247
248 return new Promise((resolve, reject) => {
249 const child = spawn(npmCommand, ['run', script], {
250 env,
251 shell: process.platform === 'win32',
252 stdio: ['ignore', 'pipe', 'pipe']
253 })
254 let output = ''
255
256 child.stdout.on('data', (chunk) => {
257 const text = String(chunk)
258 output += text
259 process.stdout.write(text)
260 })
261 child.stderr.on('data', (chunk) => {
262 const text = String(chunk)
263 output += text
264 process.stderr.write(text)
265 })
266 child.on('error', reject)
267 child.on('close', (code) => {
268 if (code === 0) {
269 resolve(parseMetrics(output, metricNames[targetName]))
270 return
271 }
272 reject(new Error(`${script} run ${runIndex + 1} exited with code ${code ?? 'unknown'}`))
273 })
274 })
275}
276
277function printSummary(targetName, samples) {
278 const names = metricNames[targetName]

Callers 1

Calls 4

targetEnvPrefixFunction · 0.85
resolveFunction · 0.85
parseMetricsFunction · 0.85
onMethod · 0.45

Tested by

no test coverage detected