'use strict'; const fs=require('node:fs'),path=require('node:path'),assert=require('node:assert/strict'); const input=process.argv[2]||'backend/reports/http-archive-benchmark.json'; const report=JSON.parse(fs.readFileSync(input,'utf8')); const median=values=>[...values].sort((a,b)=>a-b)[Math.floor(values.length/2)]; const fixtures=[...new Set(report.results.map(r=>r.fixture))]; const rows=fixtures.map(fixture=>({fixture,...Object.fromEntries(['node','go'].map(runtime=>{ const samples=report.results.filter(r=>r.fixture===fixture&&r.runtime===runtime); assert.ok(samples.length); if(samples.some(r=>r.status==='failed'))return [runtime,{failure:samples.find(r=>r.status==='failed').failure}]; return [runtime,Object.fromEntries([1,8].map(concurrency=>{ const batches=samples.map(r=>r.warm.find(w=>w.concurrency===concurrency));assert.ok(batches.every(Boolean)); return [concurrency,Object.fromEntries(['p95Ms','requestsPerSecond','peakProcessTreeRssBytes','cpuMsPerRequest'].map(metric=>[metric,median(batches.map(w=>metric==='cpuMsPerRequest'?w.cpuMs/w.requests:w[metric]))]))]; }))]; }))})); const data=JSON.stringify(rows).replaceAll('<','\\u003c'); const title='Node and Go: archive file requests'; const html=`
Real server entrypoints, disposable MongoDB and Redis, synthetic archive originals. Every successful response was checked by SHA-256.
| Fixture | Node | Go | Go / Node |
|---|
Node returned HTTP 500 for the 2 MiB text fixture: its persisted term array could not be cloned into the worker. No speedup is assigned to that failed baseline.
${report.method.quick?'Smoke run; 16 warm requests per batch.':'Three alternating-order rounds; 100 warm requests per batch.'} CPU includes worker processes and post-response view writes. RSS is sampled every 10 ms and excludes MongoDB, Redis and the load generator. Shared gzip caching, remote providers, S3 and startup are outside this workload.
`; const target=input.replace(/\.json$/,'.html');assert.notEqual(target,input);fs.writeFileSync(target,html); console.log(target); for(const row of rows)console.log(JSON.stringify(row));