const fs=require('fs'),path=require('path'); const source=path.join(__dirname,'../reports/repository-runtime-comparison.json'); const r=JSON.parse(fs.readFileSync(source)); const zipSource=path.join(__dirname,'../reports/repository-zip-node-comparison.json'); if(fs.existsSync(zipSource)){const zip=JSON.parse(fs.readFileSync(zipSource));for(const run of r.results.filter(x=>x.runtime==='node')){const correction=zip.results.find(x=>x.repeat===run.repeat);if(correction)run.results=run.results.map(x=>x.name==='repository ZIP'?correction.results[0]:x);}} const median=a=>{a=[...a].sort((a,b)=>a-b);return (a[Math.floor((a.length-1)/2)]+a[Math.floor(a.length/2)])/2}; const names=r.results[0].results.map(x=>x.name); const summary=names.map(name=>{ const out={name}; for(const runtime of ['node','go']){ const runs=r.results.filter(x=>x.runtime===runtime).map(x=>x.results.find(y=>y.name===name)); out[runtime]={status:runs[0].output.status,output:runs[0].output,coldMs:median(runs.map(x=>x.cold.ms)),diagnostic:runs.find(x=>x.diagnostic)?.diagnostic,warm:[1,8].map(c=>{ const batches=runs.flatMap(x=>x.warm.filter(y=>y.concurrency===c));if(!batches.length)return null; return {concurrency:c,p50Ms:median(batches.map(x=>x.p50Ms)),p95Ms:median(batches.map(x=>x.p95Ms)),firstBodyMs:median(batches.map(x=>x.p50FirstBodyMs)),requestsPerSecond:median(batches.map(x=>x.requestsPerSecond)),cpuMsPerRequest:median(batches.map(x=>x.cpuMs/x.requests)),peakRSSMiB:Math.max(...batches.map(x=>x.peakProcessTreeRssBytes))/1048576}; }).filter(Boolean)}; } out.outputParity=out.node.status===200&&out.go.status===200&&out.node.output.sha256===out.go.output.sha256; return out; }); fs.writeFileSync(source.replace('.json','-summary.json'),JSON.stringify({fixture:r.fixture,summary},null,2)); const html=`
${r.fixture.originalFiles.toLocaleString()} repository files plus a synthetic 1,000-file directory. Two rounds with runtime order reversed.
| Use case | TypeScript | Go | Go / TS |
|---|
Loopback HTTP, identical archive originals, filesystem storage, shared caches enabled, one anonymization worker, identity encoding. No CDN, GitHub round trips or browser rendering. TypeScript ZIP was retested with a temporary admin key and the same source ZIP served over loopback; its worker aborted both attempts. These are backend measurements, not beta page-load times.
Commit ${r.fixture.commit}. Node ${r.node}; ${r.go}. Warm results are medians of each round's p50, not pooled percentiles. Each round uses 32 requests per concurrency for normal endpoints and 3 sequential ZIP downloads. First requests can share dependencies warmed by earlier endpoints. RSS includes application workers but excludes MongoDB, Redis and the client. CPU includes background work. RSS includes caches retained from earlier cases. The OS page cache was not dropped. The selected small files contain no occurrence of the configured anonymization term; these timings do not measure replacement-heavy text.