ostia 0.1.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +438 -107
- package/chunk-qbt85kmg.js +4 -0
- package/chunk-r5b8vf8w.js +21 -0
- package/cli.js +132 -62
- package/index.d.ts +296 -33
- package/index.js +1 -1
- package/package.json +1 -1
- package/runner.ts +5 -4
- package/chunk-3qbcj1m9.js +0 -21
- package/chunk-zrck2q0b.js +0 -4
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function k(s){return JSON.stringify(me(s))}function me(s){if(Array.isArray(s))return s.map(me);if(s!==null&&typeof s==="object"){let c={};for(let l of Object.keys(s).sort())c[l]=me(s[l]);return c}return s}function e(s,...c){let l=Bun.CryptoHasher.hash("sha256",k(c),"hex");return`${s}_${l.slice(0,16)}`}var pe,Te=!1;function ge(s){let c=Bun.spawnSync(["git",...s],{timeout:200,stdout:"pipe",stderr:"ignore"});return c.success?c.stdout.toString().trim():void 0}function ye(){if(Te)return pe;Te=!0;try{let s=ge(["rev-parse","--short","HEAD"]);if(s===void 0)pe=void 0;else{let c=ge(["rev-parse","--abbrev-ref","HEAD"]),l=ge(["status","--porcelain"]);pe={sha:s,branch:c??"HEAD",dirty:(l?.length??0)>0}}}catch{pe=void 0}return pe}var m="0.1.0";function n(s,c,l){let w=ye();return{schemaVersion:2,toolVersion:m,bunVersion:Bun.version,platform:{os:process.platform,arch:process.arch},createdAt:new Date().toISOString(),workloads:s,measurements:c,...l!==void 0&&{environment:l},...w!==void 0&&{git:w}}}function p(s,c){return{id:e("wl","subprocess",s,process.cwd()),kind:"subprocess",command:s,label:c}}function D(s,c){return{id:e("wl","inprocess",s.name,s.toString()),kind:"inprocess",label:c}}function N(s,c,l={}){return{id:l.params!==void 0?e("wl","inprocess-entry",s,c,l.params):e("wl","inprocess-entry",s,c),kind:"inprocess",entry:{file:s,task:c,...l.group!==void 0&&{group:l.group}},...l.label!==void 0&&{label:l.label},...l.baseline!==void 0&&{baseline:l.baseline},...l.description!==void 0&&{description:l.description},...l.groupDescription!==void 0&&{groupDescription:l.groupDescription},...l.isolated!==void 0&&{isolated:l.isolated},...l.params!==void 0&&{params:l.params},...l.skipped!==void 0&&{skipped:l.skipped}}}function i(s){return{id:e("run",s.workload.id,"timing",s.configFingerprint,Bun.version,m),workloadId:s.workload.id,phase:"timing",instrumented:!1,configFingerprint:s.configFingerprint,trials:s.trials,timing:s.timing,warnings:s.warnings,artifacts:[],memory:Ne(s.trials),...s.interleaved!==void 0&&{interleaved:s.interleaved}}}function Ne(s){let c=s.map((l)=>l.maxRssBytes).filter((l)=>l!==void 0);if(c.length===0)return;return{origin:"resourceUsage",perTrial:s.map((l)=>({rssBytes:l.maxRssBytes})),maxRssBytes:Math.max(...c)}}function a(s){return{id:e("run",s.workload.id,s.phase,s.configFingerprint,Bun.version,m),workloadId:s.workload.id,phase:s.phase,instrumented:!0,configFingerprint:s.configFingerprint,trials:[{i:0,wallNs:s.diagnosticWallNs,exitCode:s.exitCode}],diagnosticWallNs:s.diagnosticWallNs,cpu:s.cpu,heap:s.heap,memory:s.memory,jit:s.jit,warnings:s.warnings,artifacts:s.artifacts}}async function S(s,c,l){let v=await Bun.file(l).arrayBuffer(),R=new Bun.CryptoHasher("sha256");return R.update(v),{id:e("art",s,c,l),kind:c,path:l,sha256:R.digest("hex"),bytes:v.byteLength}}function o(s){return e("cfg",s)}function M(s){return`${JSON.stringify(me(s),null,2)}
|
|
3
|
+
`}async function r(s,c){await Bun.write(c,M(s))}function Oe(s){if(s.schemaVersion===2)return s;let{runs:c,comparisons:l,...w}=s;return{...w,schemaVersion:2,measurements:c.map(({baselineRunId:v,...R})=>({...R,...v!==void 0&&{baselineMeasurementId:v}})),...l!==void 0&&{comparisons:l.map(({baselineRunId:v,candidateRunId:R,...I})=>({...I,baselineMeasurementId:v,candidateMeasurementId:R}))}}}async function t(s){let c=await Bun.file(s).text(),l=JSON.parse(c);return Oe(l)}import{profile as Pe}from"bun:jsc";var Ae=new Map([["LLInt","llint"],["Baseline","baseline"],["DFG","dfg"],["FTL","ftl"]]),xe=4294967295;function Me(s,c){let l=c??s.interval*1e6,w=new Map,v=[];function R(b,T,P,Z){let Q=w.get(b);if(Q===void 0)Q=new Map,w.set(b,Q);let X=T??"",te=Q.get(X);if(te===void 0)te=v.length,Q.set(X,te),v.push({key:e("fr",b,X),name:b,url:T,line:P,col:Z});return te}function I(b){let T=b.line===xe,P=T?void 0:b.line-1,Z=T||b.column===xe?void 0:b.column-1;return R(b.name,b.sourceURL,P,Z)}let J=R("(root)",void 0,void 0,void 0),_=1,q={id:0,frameIx:J,children:new Map,selfUs:0,samples:0,totalUs:0},ne=new Map([[0,q]]),Y={llint:0,baseline:0,dfg:0,ftl:0},H=new Map,ue=[],oe=[];for(let b of s.traces){let T=b.frames,P=q;for(let X=T.length-1;X>=0;X--){let te=I(T[X]),le=P.children.get(te);if(!le)le={id:_++,frameIx:te,children:new Map,selfUs:0,samples:0,totalUs:0},P.children.set(te,le),ne.set(le.id,le);P=le}P.selfUs+=l,P.samples+=1,ue.push(P.id),oe.push(l);let Z=T[0],Q=Z&&Ae.get(Z.category);if(Q){Y[Q]++;let X=H.get(Q)??new Map;X.set(P.frameIx,(X.get(P.frameIx)??0)+1),H.set(Q,X)}}function ee(b){let T=b.selfUs;for(let P of b.children.values())T+=ee(P);return b.totalUs=T,T}ee(q);let se=new Map;function re(b){let T=se.get(b.frameIx);if(T)T.selfUs+=b.selfUs,T.totalUs+=b.totalUs,T.samples+=b.samples;else se.set(b.frameIx,{frameIx:b.frameIx,selfUs:b.selfUs,totalUs:b.totalUs,samples:b.samples});for(let P of b.children.values())re(P)}re(q);let ie=[...ne.values()].map((b)=>({id:b.id,frameIx:b.frameIx,children:[...b.children.values()].map((T)=>T.id)})),ae={origin:"jsc-profile",samplingIntervalUs:l,frames:v,nodes:ie,totals:[...se.values()].sort((b,T)=>T.selfUs-b.selfUs),samples:{nodeIds:ue,timeDeltasUs:oe}},L=[...H.entries()].flatMap(([b,T])=>[...T.entries()].sort((P,Z)=>Z[1]-P[1]).slice(0,3).map(([P,Z])=>({tier:b,frameKey:v[P].key,samples:Z})));return{cpu:ae,jit:{origin:"jsc-profile",tiers:Y,topFramesByTier:L}}}var Ue=1000;async function d(s,c={}){let l=c.intervalUs??Ue,w,v=Bun.nanoseconds(),R=await Pe(async()=>(w=await s(),w),l),I=Bun.nanoseconds()-v,{cpu:J,jit:_}=Me(R.stackTraces,l);return{result:w,cpu:J,jit:_,diagnosticWallNs:I}}import be from"os";function u(s){if(s.length===0)throw Error("computeTimingStats: samples must be non-empty");let c=s.length,l=ve(s),w=0;for(let b=0;b<c;b++)w+=s[b];let v=w/c,R=ce(l,0.5),I=0;for(let b=0;b<c;b++){let T=s[b]-v;I+=T*T}let J=Math.sqrt(I/c),_=l[0],q=l[c-1],ne=ce(l,0.25),Y=ce(l,0.75),H=Y-ne,ue=ne-1.5*H,oe=Y+1.5*H,ee=ne-3*H,se=Y+3*H,re=0,ie=0;for(let b=0;b<c;b++){let T=s[b];if(T<ee||T>se)ie++;else if(T<ue||T>oe)re++}let ae=ce(l,0.99),L=new Float64Array(c);for(let b=0;b<c;b++)L[b]=Math.abs(s[b]-R);L.sort();let K=ce(L,0.5);return{unit:"ns",samples:s,mean:v,median:R,stddev:J,min:_,max:q,outliers:{mild:re,severe:ie},p75:Y,p99:ae,mad:K}}function ve(s){let c=new Float64Array(s.length);return c.set(s),c.sort(),c}function ce(s,c){let l=s.length;if(l===1)return s[0];let w=c*(l-1),v=Math.floor(w),R=Math.ceil(w);if(v===R)return s[v];let I=w-v;return s[v]*(1-I)+s[R]*I}var De=5000000,_e=200;function y(s,c,l="subprocess"){let w=[],v=s.samples[0];if(v!==void 0){let I=ve(s.samples),J=ce(I,0.25),q=ce(I,0.75)-J;if(v>s.median+3*q&&q>0)w.push({code:"slow-first-run",message:`First run took ${(v/1e6).toFixed(2)}ms, much slower than the median ${(s.median/1e6).toFixed(2)}ms. Consider more warmup.`,data:{firstNs:v,medianNs:s.median}})}if(s.outliers.mild+s.outliers.severe>0)w.push({code:"outliers-detected",message:`${s.outliers.mild+s.outliers.severe} outlier(s) detected (${s.outliers.severe} severe, ${s.outliers.mild} mild).`,data:s.outliers});if(l==="subprocess"&&s.median<De)w.push({code:"fast-command",message:`Median run time (${(s.median/1e6).toFixed(3)}ms) is very fast; results may be dominated by spawn overhead.`,data:{medianNs:s.median}});if(l==="inprocess"&&s.median<_e)w.push({code:"below-timer-resolution",message:`Median run time (${s.median.toFixed(0)}ns) is close to timer resolution; consider a larger batch size or a coarser operation.`,data:{medianNs:s.median}});let R=c.filter((I)=>I!==void 0&&I!==0);if(R.length>0)w.push({code:"nonzero-exit",message:`${R.length} of ${c.length} trial(s) exited non-zero.`,data:{exitCodes:R}});return w}var Ce=200,Re=64,We=(()=>{let s=new Uint8Array(4096);for(let c=0;c<s.length;c++)s[c]=c*2654435761&255;return s})();function Ge(s,c){let l=c;for(let w=0;w<s.length;w++)l^=s[w],l=Math.imul(l,16777619);return l>>>0}function Le(s){let c=u(s),l=c.mad??0;return{floorPct:c.median===0?0:l/c.median*100,referenceMedianNs:c.median,samples:s.length}}function Ie(s=Ce){let c=s*1e6,l=[],w=0,v=Bun.nanoseconds(),R=0;while(R<c){let I=Bun.nanoseconds();for(let _=0;_<Re;_++)w^=Ge(We,_);let J=Bun.nanoseconds();l.push((J-I)/Re),R=Bun.nanoseconds()-v}return Le(l)}var Je=0.75;function f(){let[s=0,c=0]=be.loadavg();return{cpuModel:be.cpus()[0]?.model??"unknown",cores:be.availableParallelism(),loadAvg1:s,loadAvg5:c,noise:Ie()}}function g(s){if(s.loadAvg1<=s.cores*Je)return;return{code:"noisy-machine",message:`Load average ${s.loadAvg1.toFixed(2)} exceeds 75% of ${s.cores} available core(s); timing noise may be elevated.`,data:{loadAvg1:s.loadAvg1,cores:s.cores}}}var He=500,$e=20,Fe=3,je=10,Ve=2,qe=0.1,ze=1000,Ke=1e4;function Se(s){let c=Math.log10(Math.max(1,s)/1e6),l=Math.round(Fe+Ve*c);return Math.min(je,Math.max(Fe,l))}function Xe(s,c){let l=Math.floor(c/s);return Math.min($e,Math.max(l,Se(s)))}var Ee=0;function x(s){if(typeof s==="number")Ee+=s;else if(s!==void 0&&s!==null)Ee+=1}function fe(s){return s!==null&&typeof s==="object"&&typeof s.then==="function"}function Be(s,c){return Math.max(1,Math.ceil(ze/s),Math.ceil(c/(s*Ke)))}async function F(s,c={}){let l=(c.budgetMs??He)*1e6,w=l*(c.warmup??qe),v=Bun.nanoseconds(),R=0,I=0;while(I<w){let L=s();x(fe(L)?await L:L),R++,I=Bun.nanoseconds()-v}let J;if(R>0)J=Math.max(1,I/R);else{let L=Bun.nanoseconds(),K=s();x(fe(K)?await K:K),J=Math.max(1,Bun.nanoseconds()-L)}let _=Be(J,l);if(_>1){let L=Bun.nanoseconds();for(let K=0;K<_;K++){let b=s();x(fe(b)?await b:b)}J=Math.max(1,(Bun.nanoseconds()-L)/_),_=Be(J,l)}let q=J*_,ne=c.samples??c.minSamples??Xe(q,l),Y=c.samples!==void 0?0:l,H=[],ue=Bun.nanoseconds(),oe=0,ee=0;while(ee<ne||oe<Y){let L=Bun.nanoseconds();for(let b=0;b<_;b++){let T=s();x(fe(T)?await T:T)}let K=Bun.nanoseconds();if(H.push({i:ee,wallNs:(K-L)/_}),ee++,oe=Bun.nanoseconds()-ue,c.gc)Bun.gc(!0);if(c.samples!==void 0&&ee>=c.samples)break}let se=H.map((L)=>L.wallNs),re=u(se),ie=y(re,[],"inprocess"),ae=Se(q);if(H.length<ae)ie.push({code:"low-sample-count",message:`Only ${H.length} sample(s) at ~${Ze(q)} per trial; ${ae} is the floor for this cost class. Raise minSamples or the time budget for a steadier number.`,data:{samples:H.length,target:ae,trialCostNs:q}});return{trials:H,timing:re,warnings:ie}}function Ze(s){if(s>=1e9)return`${(s/1e9).toFixed(2)}s`;if(s>=1e6)return`${(s/1e6).toFixed(1)}ms`;if(s>=1000)return`${(s/1000).toFixed(1)}\xB5s`;return`${s.toFixed(0)}ns`}var he=[],z,de;function ke(s,c,l,w){let v=z;z={name:s,description:l?.description,isolate:l?.isolate,gc:l?.gc,cpu:l?.cpu,alloc:l?.alloc,before:l?.before,after:l?.after,skip:w.skip,only:w.only};try{c()}finally{z=v}}var V=Object.assign((s,c,l)=>ke(s,c,l,{}),{skip:(s,c,l)=>ke(s,c,l,{skip:!0}),only:(s,c,l)=>ke(s,c,l,{only:!0})});function we(s,c,l,w){let v=de!==void 0||l?.params!==void 0?{...de,...l?.params}:void 0;he.push({groupName:z?.name,groupDescription:z?.description,groupIsolate:z?.isolate,groupGc:z?.gc,groupCpu:z?.cpu,groupAlloc:z?.alloc,groupBefore:z?.before,groupAfter:z?.after,name:s,fn:c,baseline:l?.baseline,params:v,skipped:w.skip||z?.skip,only:w.only||z?.only,opts:l})}var G=Object.assign((s,c,l)=>we(s,c,l,{}),{skip:(s,c,l)=>we(s,c,l,{skip:!0}),only:(s,c,l)=>we(s,c,l,{only:!0})});function O(){return he}function B(){he.length=0,z=void 0,de=void 0}function E(s,c){let l=de;de=s;try{return c()}finally{de=l}}function h(s){return s.groupName?`${s.groupName}/${s.name}`:s.name}function C(s,c){return s.opts?.isolate??s.groupIsolate??c}function U(s,c){return s.opts?.gc??s.groupGc??c}function W(s,c){return s.opts?.cpu??s.groupCpu??c}function A(s,c){return s.opts?.alloc??s.groupAlloc??c}function j(s,c){if(!c)return[...s];let l=new RegExp(c);return s.filter((w)=>l.test(h(w)))}
|
|
4
|
+
export{k,e,m,n,p,D,N,i,a,S,o,M,r,t,u,y,d,f,g,x,F,V,G,O,B,E,h,C,U,W,A,j};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{k,e,n,p,D,i,a,S,o,M,t,u,y,d,f,g,E}from"./chunk-qbt85kmg.js";function yn(r){return r.startsWith("file://")?r.slice(7):r}function we(r,h,m){let x=r.nodes,N=x.length,F=new Map,C=[],O=new Map,W=new Int32Array(N);for(let V=0;V<N;V++){let G=x[V],q=G.callFrame,te=yn(q.url),ne=F.get(q.functionName);if(ne===void 0)ne=new Map,F.set(q.functionName,ne);let oe=ne.get(te);if(oe===void 0)oe=C.length,ne.set(te,oe),C.push({key:e("fr",q.functionName,te),name:q.functionName,url:te||void 0,line:q.lineNumber>=0?q.lineNumber:void 0,col:q.columnNumber>=0?q.columnNumber:void 0});W[V]=oe,O.set(G.id,V)}let U=Array(N);for(let V=0;V<N;V++){let G=x[V];U[V]={id:G.id,frameIx:W[O.get(G.id)],children:G.children??[]}}let B=new Float64Array(N),j=new Float64Array(N),{samples:z,timeDeltas:A}=r;for(let V=0;V<z.length;V++){let G=O.get(z[V]);if(G===void 0)continue;B[G]+=A[V]??0,j[G]+=1}let Y=new Int32Array(N).fill(-1);for(let V=0;V<N;V++){let G=x[V].children;if(!G)continue;for(let q of G){let te=O.get(q);if(te!==void 0)Y[te]=V}}let K=[],Z=[];for(let V=N-1;V>=0;V--)if(Y[V]===-1)Z.push(V);while(Z.length>0){let V=Z.pop();K.push(V);let G=x[V].children;if(!G)continue;for(let q of G){let te=O.get(q);if(te!==void 0&&Y[te]===V)Z.push(te)}}let ee=new Float64Array(N);for(let V=K.length-1;V>=0;V--){let G=K[V];ee[G]+=B[G];let q=Y[G];if(q>=0)ee[q]+=ee[G]}let re=Array(C.length),X=[];for(let V=0;V<N;V++){let G=U[V].frameIx,q=re[G];if(q)q.selfUs+=B[V],q.totalUs+=ee[V],q.samples+=j[V];else{let te={frameIx:G,selfUs:B[V],totalUs:ee[V],samples:j[V]};re[G]=te,X.push(te)}}return{origin:h,samplingIntervalUs:m,frames:C,nodes:U,totals:X.sort((V,G)=>G.selfUs-V.selfUs),samples:{nodeIds:r.samples,timeDeltasUs:r.timeDeltas}}}function wn(r,h,m,x){let N=["--cpu-prof","--cpu-prof-dir",h,"--cpu-prof-name",m,"--cpu-prof-interval",String(x)],F=r[0];if(F==="bun"||F?.endsWith("/bun"))return[F,...N,...r.slice(1)];return r}async function Se(r){let h=`${r.artifactDir}/${r.fileName}`,m=r.argv[0],x=m==="bun"||m?.endsWith("/bun"),N=wn(r.argv,r.artifactDir,r.fileName,r.intervalUs),F=x?r.env:{...process.env,...r.env,BUN_OPTIONS:`--cpu-prof --cpu-prof-dir ${r.artifactDir} --cpu-prof-name ${r.fileName} --cpu-prof-interval ${r.intervalUs}`},C=Bun.nanoseconds(),W=await Bun.spawn(N,{cwd:r.cwd,env:F,stdout:"ignore",stderr:"ignore",stdin:"ignore"}).exited,U=Bun.nanoseconds()-C,B=Bun.file(h);if(!await B.exists())return{diagnosticWallNs:U,exitCode:W,warnings:[{code:"artifact-missing",message:`Expected a .cpuprofile at ${h} after exit ${W}, found nothing. The workload's argv[0] must be a \`bun\` binary for CPU capture.`,data:{artifactPath:h,argv:r.argv}}]};let j=await B.json(),z=we(j,"cpu-prof",r.intervalUs),A=j.samples.length===0?[{code:"empty-profile",message:"CPU capture produced zero samples."}]:[];return{diagnosticWallNs:U,exitCode:W,artifactPath:h,cpu:z,warnings:A}}function Ne(r,h="heap-prof"){let{node_fields:m,node_types:x}=r.snapshot.meta,N=m.indexOf("type"),F=m.indexOf("self_size"),C=m.length,O=x[0];if(N===-1||F===-1||!Array.isArray(O))return{origin:h,typeCounts:[],objectCount:r.snapshot.node_count};let W=O.length,U=Array(W),B=new Map,j=[],z=0,A=r.nodes,Y=A.length;for(let X=0;X<Y;X+=C){let V=A[X+N],G=A[X+F]??0;z+=G;let q;if(V>=0&&V<W){if(q=U[V],q===void 0)q={type:O[V],count:0,bytes:0},U[V]=q,j.push(q)}else{let te=`unknown(${V})`;if(q=B.get(te),q===void 0)q={type:te,count:0,bytes:0},B.set(te,q),j.push(q)}q.count++,q.bytes+=G}let K=j.sort((X,V)=>V.count-X.count),Z=K.slice(0,20),ee=K.slice(20),re=Z.map(({type:X,count:V,bytes:G})=>({type:X,count:V,retainedBytes:G}));if(ee.length>0){let X=0,V=0;for(let G of ee)X+=G.count,V+=G.bytes;re.push({type:"other",count:X,retainedBytes:V})}return{origin:h,heapSizeBytes:z,objectCount:r.snapshot.node_count,typeCounts:re}}function xn(r,h,m){let x=["--heap-prof","--heap-prof-dir",h,"--heap-prof-name",m],N=r[0];if(N==="bun"||N?.endsWith("/bun"))return[N,...x,...r.slice(1)];return r}async function Fe(r){let h=`${r.artifactDir}/${r.fileName}`,m=r.argv[0],x=m==="bun"||m?.endsWith("/bun"),N=xn(r.argv,r.artifactDir,r.fileName),F=x?r.env:{...process.env,...r.env,BUN_OPTIONS:`--heap-prof --heap-prof-dir ${r.artifactDir} --heap-prof-name ${r.fileName}`},C=Bun.nanoseconds(),W=await Bun.spawn(N,{cwd:r.cwd,env:F,stdout:"ignore",stderr:"ignore",stdin:"ignore"}).exited,U=Bun.nanoseconds()-C,B=Bun.file(h);if(!await B.exists())return{diagnosticWallNs:U,exitCode:W,warnings:[{code:"artifact-missing",message:`Expected a heap snapshot at ${h} after exit ${W}, found nothing. The workload's argv[0] must be a \`bun\` binary for heap capture.`,data:{artifactPath:h,argv:r.argv}}]};let j=await B.json(),z=Ne(j,"heap-prof");return{diagnosticWallNs:U,exitCode:W,artifactPath:h,heap:z,warnings:[]}}import{Session as kn}from"inspector/promises";var Pn=1000;async function Ue(r,h={}){let m=h.intervalUs??Pn,x=new kn;x.connect();let N=Bun.nanoseconds();try{await x.post("Profiler.enable"),await x.post("Profiler.setSamplingInterval",{interval:m}),await x.post("Profiler.start");let F=await r(),{profile:C}=await x.post("Profiler.stop"),O=Bun.nanoseconds()-N,W=we(C,"inspector",m);return{result:F,cpu:W,diagnosticWallNs:O}}finally{x.disconnect()}}async function ve(r){let h=Bun.nanoseconds(),m=Bun.spawn(r.argv,{cwd:r.cwd,env:r.env,stdout:"ignore",stderr:"ignore",stdin:"ignore"}),x=await m.exited,N=Bun.nanoseconds(),F=m.resourceUsage?.();return{wallNs:N-h,exitCode:x,userNs:F?Number(F.cpuTime.user)*1000:void 0,systemNs:F?Number(F.cpuTime.system)*1000:void 0,maxRssBytes:F?.maxRSS}}function We(r){return r.trim().split(/\s+/).filter(Boolean)}var $n=10,Rn=3000000000,Mn=3;function Te(r){let h=r.warmup??Mn,m=r.samples,x=r.minSamples??$n,N=m??x,F=m!==void 0?0:r.budgetMs!==void 0?r.budgetMs*1e6:Rn,C=[],O=0,W=0;function U(){if(m!==void 0)return W>=m;return W>=N&&O>=F}return{async warmup(){for(let B=0;B<h;B++)await ve(r)},async step(){if(U())return!1;let B=await ve(r);return C.push({i:W,wallNs:B.wallNs,exitCode:B.exitCode,userNs:B.userNs,systemNs:B.systemNs,maxRssBytes:B.maxRssBytes}),O+=B.wallNs,W++,!0},done:U,result(){let B=C.map((A)=>A.wallNs),j=u(B),z=y(j,C.map((A)=>A.exitCode));return{trials:C,timing:j,warnings:z}}}}async function w(r){let h=Te(r);await h.warmup();while(await h.step());return h.result()}var Oe=new URL("./runner.ts",import.meta.url).pathname,vn="node_modules/.cache/ostia";function P(){return Math.max(1,navigator.hardwareConcurrency||1)}async function T(r,h){let m=new Set;for(let x of r){let N=new Bun.Glob(x);for await(let F of N.scan({cwd:h,absolute:!1}))m.add(F)}return[...m].sort()}function Tn(r){if(r===void 0)return;return r==="auto"?P():r}async function I(r,h,m=process.cwd()){return{suites:r.suites.length>0?r.suites:h?.suites?await T(h.suites,m):[],budgetMs:r.budgetMs??h?.budgetMs,samples:r.samples??h?.samples,minSamples:r.minSamples??h?.minSamples,jobs:r.jobs??Tn(h?.jobs),gc:r.gc||(h?.gc??!1),cpu:r.cpu||(h?.cpu??!1),alloc:r.alloc||(h?.alloc??!1),filter:r.filter??h?.filter,isolate:r.isolate||(h?.isolate??!1),preload:r.preload.length>0?r.preload:h?.preload??[],bunFlags:r.bunFlags,outDir:r.outDir??h?.outDir,noiseCheck:r.noiseCheck,cwd:m}}async function c(r){let m=`${r.outDir??vn}/bench-tmp`,x=r.cwd??process.cwd(),N=Math.max(1,Math.floor(r.jobs??1)),F={budgetMs:r.budgetMs,samples:r.samples,minSamples:r.minSamples,gc:r.gc,cpu:r.cpu,alloc:r.alloc,noiseCheck:r.noiseCheck},C=r.suites.map((B)=>B.startsWith("/")?B:`${x}/${B}`),O=(r.preload??[]).map((B)=>B.startsWith("/")?B:`${x}/${B}`),W=r.bunFlags??[],U=async(B,j)=>{let z=new Set,A=0,Y,K=async()=>{while(Y===void 0&&A<B.length){let Z=A++;try{let ee=Bun.spawn(B[Z],{cwd:x,stdout:"inherit",stderr:"inherit",stdin:"ignore"});z.add(ee);let re=await ee.exited;if(z.delete(ee),re!==0)throw Error(`Bench suite failed: ${j(Z)} (runner exited ${re})`)}catch(ee){Y??=ee instanceof Error?ee:Error(String(ee));for(let re of z)re.kill()}}};if(await Promise.all(Array.from({length:Math.min(N,B.length)},K)),Y)throw Y};try{let B=C.map((G)=>`${m}/${e("bench-plan",G)}.json`),j=C.map((G)=>`${m}/${e("bench-primary",G)}.json`),z=C.map((G,q)=>["bun",...W,Oe,G,j[q],JSON.stringify({...F,filter:r.filter,isolate:r.isolate,preload:O,planPath:B[q]})]);await U(z,(G)=>r.suites[G]);let A=await Promise.all(B.map(async(G)=>{let{tasks:q}=await Bun.file(G).json();return q})),Y=await Promise.all(j.map(t)),K=[];for(let G=0;G<A.length;G++)for(let q of A[G])if(q.isolate)K.push({suiteIndex:G,taskIds:[q.id]});let Z=K.map((G,q)=>`${m}/${e("bench-item",C[G.suiteIndex],q)}.json`),ee=K.map((G,q)=>["bun",...W,Oe,C[G.suiteIndex],Z[q],JSON.stringify({...F,taskIds:G.taskIds,preload:O,markIsolated:!0})]);await U(ee,(G)=>r.suites[K[G].suiteIndex]);let re=await Promise.all(Z.map(t)),X=[],V=[];for(let G=0;G<A.length;G++){let q=Y[G],te=new Map;for(let Q of q.measurements){let se=te.get(Q.workloadId)??[];se.push(Q),te.set(Q.workloadId,se)}let ne=0,oe=new Map;K.forEach((Q,se)=>{if(Q.suiteIndex===G)oe.set(Q.taskIds[0],re[se])});for(let Q of A[G])if(Q.isolate){let se=oe.get(Q.id),me=se.workloads[0];X.push(me);for(let le of se.measurements)if(le.workloadId===me.id)V.push(le)}else{let se=q.workloads[ne];X.push(se),ne++;for(let me of te.get(se.id)??[])V.push(me)}}return n(X,V,Y[0]?.environment)}finally{await Bun.spawn(["rm","-rf",m]).exited}}function _(r,h,m=8){if(m<=1)throw RangeError(`range: multiplier must be > 1, got ${m}`);if(r<=0)throw RangeError(`range: start must be > 0, got ${r}`);let x=[];for(let N=r;N<=h;N*=m)x.push(N);if(!x.includes(h))x.push(h);return x}function L(r,h){let m=Object.keys(r),x=(N,F)=>{if(N===m.length){E(F,()=>h(F));return}let C=m[N];for(let O of r[C])x(N+1,{...F,[C]:O})};x(0,{})}function Cn(r){let h=r>>>0;return()=>{h=h+1831565813|0;let m=Math.imul(h^h>>>15,1|h);return m=m+Math.imul(m^m>>>7,61|m)^m,((m^m>>>14)>>>0)/4294967296}}var xe=2000,In=2000;function je(r){let h=r.length,m=h>>1;return h%2===0?(r[m-1]+r[m])/2:r[m]}function Be(r,h){let m=r.length;if(m===1)return r[0];let x=h*(m-1),N=Math.floor(x),F=Math.ceil(x);if(N===F)return r[N];let C=x-N;return r[N]*(1-C)+r[F]*C}function Ee(r,h,m){if(r.length<=m)return r;let x=[...r];for(let N=0;N<m;N++){let F=N+Math.floor(h()*(x.length-N)),C=x[N];x[N]=x[F],x[F]=C}return x.slice(0,m)}function Ae(r,h){let m=r.length,x=new Float64Array(m);for(let N=0;N<m;N++)x[N]=r[Math.floor(h()*m)];return x.sort(),je(x)}function _e(r,h,m={}){let x=m.seed??(Date.now()^Math.imul(r.length,2654435761))>>>0,N=Cn(x),F=m.iterations??In,C=r.length>xe||h.length>xe,O=Ee(r,N,xe),W=Ee(h,N,xe),U=new Float64Array(O);U.sort();let B=je(U),j=new Float64Array(F);for(let z=0;z<F;z++){let A=Ae(O,N),Y=Ae(W,N);j[z]=B===0?Y-A===0?0:1/0:(Y-A)/B*100}return j.sort(),{ci95:[Be(j,0.025),Be(j,0.975)],seed:x,data:{subsampled:C,iterations:F}}}function Dn(r){let h=r<0?-1:1,m=Math.abs(r),x=0.254829592,N=-0.284496736,F=1.421413741,C=-1.453152027,O=1.061405429,W=0.3275911,U=1/(1+0.3275911*m),B=1-((((1.061405429*U+-1.453152027)*U+1.421413741)*U+-0.284496736)*U+0.254829592)*U*Math.exp(-m*m);return h*B}function Sn(r){return 0.5*(1+Dn(r/Math.SQRT2))}function Le(r,h){let m=r.length,x=h.length,N=m+x,F=[...r.map((K)=>({v:K,group:0})),...h.map((K)=>({v:K,group:1}))].sort((K,Z)=>K.v-Z.v),C=new Float64Array(N),O=0,W=0;while(W<N){let K=W;while(K+1<N&&F[K+1].v===F[W].v)K++;let Z=(W+K)/2+1;for(let re=W;re<=K;re++)C[re]=Z;let ee=K-W+1;if(ee>1)O+=ee**3-ee;W=K+1}let U=0;for(let K=0;K<N;K++)if(F[K].group===0)U+=C[K];let B=U-m*(m+1)/2,j=m*x/2,z=Math.sqrt(m*x*(N+1-O/(N*(N-1)))/12),A=z===0?0:(B-j)/z,Y=Math.min(1,Math.max(0,2*(1-Sn(Math.abs(A)))));return{u:B,z:A,pValue:Y}}var l={timingPct:5,frameSelfPct:10,heapTypePct:10,minFrameSelfUs:1000,alpha:0.01,bootstrapIterations:2000},Ce=5;function ke(r,h){if(r===0)return h===0?0:1/0;return(h-r)/r*100}function de(r,h,m){return r.measurements.find((x)=>x.workloadId===h&&x.phase===m)}function b(r,h,m=l){let x=new Set(h.workloads.map((F)=>F.id)),N=[];for(let F of r.workloads){if(!x.has(F.id))continue;let C=v(r,h,F.id,m);if(C)N.push(C)}return N}function v(r,h,m,x=l){let N=de(r,m,"timing"),F=de(h,m,"timing"),C=de(r,m,"cpu"),O=de(h,m,"cpu"),W=de(r,m,"heap"),U=de(h,m,"heap"),B=h.workloads.find((X)=>X.id===m),j=N?.id??C?.id??W?.id,z=F?.id??O?.id??U?.id??B?.id;if(!j||!z)return;let A=!1,Y=[],K=Math.max(x.timingPct,r.environment?.noise.floorPct??0,h.environment?.noise.floorPct??0),Z;if(N?.timing&&B?.skipped&&!F?.timing)Z={medianDeltaPct:0,meanDeltaPct:0,effectPct:0,verdict:"unchanged"},Y.push({code:"skipped",message:"Candidate has no timing measurement for this workload (task.skip()); treated as unchanged.",data:{workloadId:m}});else if(N?.timing&&F?.timing){let X=N.timing.samples,V=F.timing.samples,G=ke(N.timing.median,F.timing.median),q=ke(N.timing.mean,F.timing.mean);if(X.length<Ce||V.length<Ce){let te=G>K?"regressed":G<-K?"improved":"unchanged";if(te==="regressed")A=!0;Z={medianDeltaPct:G,meanDeltaPct:q,effectPct:G,verdict:te},Y.push({code:"thin-comparison",message:`Only ${X.length} baseline / ${V.length} candidate sample(s); falling back to a point-estimate threshold instead of a bootstrap CI and Mann-Whitney test (needs ${Ce}+ per side).`,data:{baseSamples:X.length,candSamples:V.length}})}else{let te=_e(X,V,{iterations:x.bootstrapIterations}),ne=Le(X,V),oe=te.ci95[0]>K&&ne.pValue<x.alpha?"regressed":te.ci95[1]<-K&&ne.pValue<x.alpha?"improved":"unchanged";if(oe==="regressed")A=!0;Z={medianDeltaPct:G,meanDeltaPct:q,effectPct:G,ci95:te.ci95,pValue:ne.pValue,seed:te.seed,verdict:oe}}}let ee;if(C?.cpu&&O?.cpu){let X=new Map(C.cpu.totals.map((ne)=>[C.cpu.frames[ne.frameIx].key,ne])),V=new Map(O.cpu.totals.map((ne)=>[O.cpu.frames[ne.frameIx].key,ne])),G=new Map(C.cpu.frames.map((ne)=>[ne.key,ne.name])),q=new Map(O.cpu.frames.map((ne)=>[ne.key,ne.name]));ee=[...new Set([...X.keys(),...V.keys()])].map((ne)=>{let oe=X.get(ne)?.selfUs??0,Q=V.get(ne)?.selfUs??0;return{frameKey:ne,name:q.get(ne)??G.get(ne)??ne,baseSelfUs:oe,candSelfUs:Q,deltaPct:ke(oe,Q)}}).sort((ne,oe)=>Math.abs(oe.deltaPct)-Math.abs(ne.deltaPct));for(let ne of ee)if((ne.baseSelfUs>=x.minFrameSelfUs||ne.candSelfUs>=x.minFrameSelfUs)&&ne.deltaPct>x.frameSelfPct)A=!0}let re;if(W?.heap&&U?.heap){let X=new Map(W.heap.typeCounts.map((q)=>[q.type,q])),V=new Map(U.heap.typeCounts.map((q)=>[q.type,q]));re=[...new Set([...X.keys(),...V.keys()])].map((q)=>{let te=X.get(q),ne=V.get(q);return{type:q,baseCount:te?.count??0,candCount:ne?.count??0,baseBytes:te?.retainedBytes,candBytes:ne?.retainedBytes,deltaPct:ke(te?.count??0,ne?.count??0)}}).sort((q,te)=>Math.abs(te.deltaPct)-Math.abs(q.deltaPct));for(let q of re)if(q.deltaPct>x.heapTypePct)A=!0}return{id:e("cmp",j,z),baselineMeasurementId:j,candidateMeasurementId:z,timing:Z,...Y.length>0&&{warnings:Y},frames:ee,heapTypes:re,thresholds:{...x,effectiveTimingPct:K},verdict:A?"fail":"pass"}}function pe(r,h){if(h){let m=r.measurements.find((x)=>x.id===h);return m?.cpu?[m]:[]}return r.measurements.filter((m)=>m.phase==="cpu"&&m.cpu)}function fe(r){let h=r.nodes,m=h.length,x=Nn(r),N=new Int32Array(m).fill(-1);for(let W=0;W<m;W++)for(let U of h[W].children){let B=x(U);if(B!==-1)N[B]=W}let F=[];for(let W=0;W<m;W++)if(N[W]===-1)F.push(W);let C=[],O=[];for(let W=F.length-1;W>=0;W--)O.push(F[W]);while(O.length>0){let W=O.pop();C.push(W);for(let U of h[W].children){let B=x(U);if(B!==-1&&N[B]===W)O.push(B)}}return{count:m,indexOf:x,parentIx:N,roots:F,order:C}}function Nn(r){let h=r.nodes,m=h.length,x=1/0,N=-1/0,F=!0;for(let O=0;O<m;O++){let W=h[O].id;if(!Number.isInteger(W)){F=!1;break}if(W<x)x=W;if(W>N)N=W}if(F&&m>0&&N-x<m*4+64){let O=N-x+1,W=new Int32Array(O).fill(-1);for(let U=0;U<m;U++)W[h[U].id-x]=U;return(U)=>{let B=U-x;return B>=0&&B<O?W[B]:-1}}let C=new Map;for(let O=0;O<m;O++)C.set(h[O].id,O);return(O)=>C.get(O)??-1}function Ve(r,h){let{count:m,indexOf:x,parentIx:N,order:F}=h,C=new Float64Array(m),O=new Float64Array(m),W=r.samples?.nodeIds??[],U=r.samples?.timeDeltasUs??[];for(let j=0;j<W.length;j++){let z=x(W[j]);if(z===-1)continue;C[z]+=U[j]??0,O[z]+=1}let B=new Float64Array(m);for(let j=F.length-1;j>=0;j--){let z=F[j];B[z]+=C[z];let A=N[z];if(A>=0)B[A]+=B[z]}return{selfUs:C,totalUs:B,samples:O}}var He={name:"collapsed",async render(r,h={}){return{files:pe(r,h.measurementId).map((N)=>{let F=N.cpu,{nodes:C,frames:O}=F,W=fe(F),U=Array(W.count);for(let Y of W.order){let K=O[C[Y].frameIx].name||"(anonymous)",Z=W.parentIx[Y];U[Y]=Z===-1?K:`${U[Z]};${K}`}let B=new Float64Array(W.count),j=[],z=F.samples?.nodeIds??[];for(let Y=0;Y<z.length;Y++){let K=W.indexOf(z[Y]);if(K===-1)continue;if(B[K]++===0)j.push(K)}let A=Array(j.length);for(let Y=0;Y<j.length;Y++){let K=j[Y];A[Y]=`${U[K]} ${B[K]}`}return{path:`${N.id}.collapsed.txt`,content:A.join(`
|
|
3
|
+
`)+(A.length>0?`
|
|
4
|
+
`:"")}})}}};var ze={name:"cpuprofile",async render(r,h={}){let m=pe(r,h.measurementId),x=[],N=[];for(let F of m){if(F.cpu?.origin!=="cpu-prof"&&F.cpu?.origin!=="inspector"){N.push(`${F.id} (origin ${F.cpu?.origin??"unknown"} has no .cpuprofile artifact to pass through)`);continue}let C=F.artifacts.find((W)=>W.kind==="cpuprofile");if(!C){N.push(`${F.id} (no cpuprofile artifact recorded on this run)`);continue}let O=Bun.file(C.path);if(!await O.exists()){N.push(`${F.id} (artifact missing on disk: ${C.path})`);continue}x.push({path:`${F.id}.cpuprofile`,content:await O.text()})}if(x.length===0&&N.length>0)return{text:`No .cpuprofile artifacts available:
|
|
5
|
+
${N.map((F)=>` - ${F}`).join(`
|
|
6
|
+
`)}
|
|
7
|
+
`};return{files:x}}};var Ke={name:"json",async render(r){return{text:M(r)}}};var Ge={name:"jsonl",async render(r){let{measurements:h,...m}=r;return{text:`${[k(m),...h.map((N)=>k(N))].join(`
|
|
8
|
+
`)}
|
|
9
|
+
`}}};var Fn={ns:1,\u{b5}s:1000,ms:1e6,s:1e9};function be(r){let h=Math.abs(r);if(h>=1e9)return"s";if(h>=1e6)return"ms";if(h>=1000)return"\xB5s";return"ns"}function Un(r){let h=Math.floor(Math.log10(Math.max(Math.abs(r),1)))+1;return Math.max(1,3-h)}function ae(r,h=be(r)){let m=r/Fn[h];return`${m.toFixed(Un(m))} ${h}`}function Pe(r){return`${r.cpuModel} \xB7 ${r.cores} cores \xB7 load ${r.loadAvg1.toFixed(1)} \xB7 noise floor ${r.noise.floorPct.toFixed(1)}%`}function Je(r){return(r/1e6).toFixed(3)}function ye(r){return r?.label??r?.command?.join(" ")??r?.entry?.task??r?.id??"unknown"}function Ye(r){if(!r?.params)return"";return` (${Object.entries(r.params).map(([m,x])=>`${m}=${x}`).join(", ")})`}function Wn(r){let h;for(let m of r){let x=m?.params?Object.keys(m.params):void 0;if(x?.length!==2)return;if(h===void 0)h=x;else if(x.length!==h.length||x.some((N,F)=>N!==h[F]))return}return h}var qe=10,Qe=10,Xe={name:"markdown",async render(r){let h=new Map(r.workloads.map((C)=>[C.id,C])),m=[];m.push("# Profile Report","");let x=r.git?` \xB7 ${r.git.sha} (${r.git.branch}${r.git.dirty?", dirty":""})`:"";if(m.push(`Bun ${r.bunVersion} \xB7 ostia ${r.toolVersion} \xB7 ${r.platform.os}/${r.platform.arch} \xB7 ${r.createdAt}${x}`,""),r.environment)m.push(Pe(r.environment),"");let N=r.measurements.filter((C)=>C.phase==="timing"&&C.timing!==void 0),F=r.workloads.filter((C)=>C.skipped&&!N.some((O)=>O.workloadId===C.id));if(N.length>0||F.length>0){m.push("## Timing","");let C=new Map,O=[];for(let B of N){let j=h.get(B.workloadId)?.entry?.group;if(j===void 0){O.push(B);continue}let z=C.get(j);if(z)z.push(B);else C.set(j,[B])}let W=new Map;for(let[B,j]of C){let z=Wn(j.map((A)=>h.get(A.workloadId)));if(z)W.set(B,{keys:z,runs:j});else O.push(...j)}if(O.length>0||F.length>0){m.push("| Task | Median | Spread (p75\u2026p99) | Mean \xB1 SD | Range | MAD |","|---|---|---|---|---|---|");for(let B of O){let j=h.get(B.workloadId),z=ye(j)+Ye(j),A=B.timing,Y=be(A.median),K=A.p75??A.median,Z=A.p99??A.max,ee=A.mad!==void 0?ae(A.mad,Y):"-";m.push(`| ${z} | ${ae(A.median,Y)} | ${ae(K,Y)}\u2026${ae(Z,Y)} | ${ae(A.mean,Y)} \xB1 ${ae(A.stddev,Y)} | ${ae(A.min,Y)}\u2026${ae(A.max,Y)} | ${ee} |`)}for(let B of F){let j=ye(B)+Ye(B);m.push(`| ${j} | - skipped | - | - | - | - |`)}m.push("")}for(let[B,{keys:j,runs:z}]of W){let[A,Y]=j,K=[],Z=[],ee=new Map;for(let re of z){let X=h.get(re.workloadId).params,V=X[A],G=X[Y];if(!K.includes(V))K.push(V);if(!Z.includes(G))Z.push(G);ee.set(`${V}\x00${G}`,re)}m.push(`### ${B} (${A} \xD7 ${Y})`,""),m.push(`| ${A} \\ ${Y} | ${Z.join(" | ")} |`,`|---|${Z.map(()=>"---").join("|")}|`);for(let re of K){let X=Z.map((V)=>{let G=ee.get(`${re}\x00${V}`);return G?ae(G.timing.median):"-"});m.push(`| ${re} | ${X.join(" | ")} |`)}m.push("")}let U=N.filter((B)=>B.warnings.length>0);if(U.length>0){m.push("### Warnings","");for(let B of U){let j=ye(h.get(B.workloadId));for(let z of B.warnings)m.push(`- **${j}**: ${z.message} (\`${z.code}\`)`)}m.push("")}}for(let C of r.measurements){if(C.phase!=="cpu"&&C.phase!=="heap")continue;let O=ye(h.get(C.workloadId));if(C.phase==="cpu"){if(m.push(`## CPU capture - ${O}`,""),m.push(`instrumented, diagnostic wall ${Je(C.diagnosticWallNs??0)}ms`,""),C.cpu){m.push(`origin: \`${C.cpu.origin}\`, interval: ${C.cpu.samplingIntervalUs}\xB5s`,""),m.push("| Self % | Self (ms) | Total (ms) | Frame |","|---|---|---|---|");let W=C.cpu.totals.reduce((U,B)=>U+B.selfUs,0)||1;for(let U of C.cpu.totals.slice(0,qe)){let B=C.cpu.frames[U.frameIx],j=(U.selfUs/W*100).toFixed(1);m.push(`| ${j}% | ${(U.selfUs/1000).toFixed(2)} | ${(U.totalUs/1000).toFixed(2)} | ${B?.name||"(anonymous)"} |`)}if(m.push(""),C.jit){let U=C.jit.tiers;m.push(`JIT tiers: LLInt ${U.llint} \xB7 Baseline ${U.baseline} \xB7 DFG ${U.dfg} \xB7 FTL ${U.ftl}`,"")}}}else if(m.push(`## Heap snapshot - ${O}`,""),m.push(`instrumented, diagnostic wall ${Je(C.diagnosticWallNs??0)}ms`,""),C.heap){m.push(`${C.heap.objectCount??"?"} objects, ${((C.heap.heapSizeBytes??0)/1e6).toFixed(2)}MB`,""),m.push("| Count | Type |","|---|---|");for(let W of C.heap.typeCounts.slice(0,Qe))m.push(`| ${W.count} | ${W.type} |`);m.push("")}for(let W of C.artifacts)m.push(`- artifact: \`${W.path}\``);for(let W of C.warnings)m.push(`- ! ${W.message} (\`${W.code}\`)`);if(C.artifacts.length>0||C.warnings.length>0)m.push("")}if(r.comparisons&&r.comparisons.length>0){m.push("## Comparisons","");for(let C of r.comparisons){let O=r.measurements.find((U)=>U.id===C.candidateMeasurementId),W=ye(O?h.get(O.workloadId):h.get(C.candidateMeasurementId));if(m.push(`### ${C.verdict==="pass"?"\u2713":"\u2717"} ${W}`,""),C.timing){let U=C.timing.medianDeltaPct>0?"+":"";m.push(`- timing: ${U}${C.timing.medianDeltaPct.toFixed(1)}% median (**${C.timing.verdict}**)`)}for(let U of C.frames?.slice(0,qe)??[]){if(Math.abs(U.deltaPct)<0.5)continue;let B=U.deltaPct>0?"+":"";m.push(`- frame \`${U.name}\`: ${B}${U.deltaPct.toFixed(1)}% self-time (${(U.baseSelfUs/1000).toFixed(2)}ms \u2192 ${(U.candSelfUs/1000).toFixed(2)}ms)`)}for(let U of C.heapTypes?.slice(0,Qe)??[]){if(Math.abs(U.deltaPct)<0.5)continue;let B=U.deltaPct>0?"+":"";m.push(`- heap \`${U.type}\`: ${B}${U.deltaPct.toFixed(1)}% count (${U.baseCount} \u2192 ${U.candCount})`)}m.push("")}}return{text:m.join(`
|
|
10
|
+
`)}}};var On=15;function Ie(r){return`n${r}`}function Bn(r,h,m){return`${(r||"(anonymous)").replace(/"/g,"'")} (self ${(h/1000).toFixed(2)}ms, total ${(m/1000).toFixed(2)}ms)`}function En(r,h,m,x){let N=[];if(x<=0)return N;for(let F=0;F<h;F++){if(F===m)continue;let C=r[F];if(N.length===x&&C<=r[N[x-1]])continue;let O=N.length;while(O>0&&r[N[O-1]]<C)O--;if(N.splice(O,0,F),N.length>x)N.pop()}return N}var Ze={name:"mermaid",async render(r,h={}){let m=h.topN??On;return{files:pe(r,h.measurementId).map((F)=>{let C=F.cpu,{nodes:O,frames:W}=C,U=fe(C),{selfUs:B,totalUs:j}=Ve(C,U),{parentIx:z}=U,A=U.roots[0]??-1,Y=En(B,U.count,A,m),K=new Set(A!==-1?[A]:[]),Z=[];for(let re of Y){Z.length=0;for(let X=re;X!==-1;X=z[X])Z.push(X);for(let X=Z.length-1;X>=0;X--)K.add(Z[X])}let ee=["graph TD"];for(let re of K){let X=O[re].id;ee.push(` ${Ie(X)}["${Bn(W[O[re].frameIx].name,B[re],j[re])}"]`)}for(let re of K){let X=z[re];if(X!==-1&&K.has(X))ee.push(` ${Ie(O[X].id)} --> ${Ie(O[re].id)}`)}return{path:`${F.id}.mermaid.md`,content:`${ee.join(`
|
|
11
|
+
`)}
|
|
12
|
+
`}})}}};function en(r){if(!r?.entry)return;if(r.entry.group!==void 0)return r.entry.group;let h=r.entry.task,m=h.lastIndexOf("/");return m===-1?void 0:h.slice(0,m)}function $e(r){let h=Math.min(...r.map((N)=>N.run.timing.median)),m=new Map;for(let N of r){let F=en(N.workload);if(F===void 0)continue;let C=m.get(F);if(C)C.push(N);else m.set(F,[N])}let x=new Map;for(let N of r){let F=en(N.workload);if(F===void 0){x.set(N,h);continue}let C=m.get(F)??[N],O=C.find((W)=>W.workload?.baseline);x.set(N,O?O.run.timing.median:Math.min(...C.map((W)=>W.run.timing.median)))}return x}function ie(r){return Number.isFinite(r)?Number(r.toPrecision(6)):r}function An(r,h){return r?.entry?.task??r?.label??r?.command?.join(" ")??h.workloadId}function jn(r,h){let m={task:r.entry?.task??r.label??r.id,skipped:!0,warnings:[]};if(r.entry?.group!==void 0)m.group=r.entry.group;if(r.description!==void 0)m.description=r.description;if(r.groupDescription!==void 0)m.groupDescription=r.groupDescription;if(r.params!==void 0)m.params=r.params;if(h?.timing)m.delta={medianPct:ie(h.timing.medianDeltaPct),meanPct:ie(h.timing.meanDeltaPct),verdict:h.timing.verdict,pass:h.verdict==="pass"};return m}function _n(r){let h=new Map(r.workloads.map((U)=>[U.id,U])),m=r.measurements.filter((U)=>U.phase==="timing"&&U.timing!==void 0).map((U)=>({run:U,workload:h.get(U.workloadId)})),x=m.length>1?$e(m):void 0,N=new Map((r.comparisons??[]).map((U)=>[U.candidateMeasurementId,U])),F=new Set(m.map((U)=>U.run.workloadId)),C=new Map;for(let U of r.measurements){if(U.phase!=="cpu"||U.warnings.length===0)continue;let B=C.get(U.workloadId)??[];C.set(U.workloadId,[...B,...U.warnings])}let O=r.workloads.filter((U)=>U.skipped&&!F.has(U.id)).map((U)=>jn(U,N.get(U.id)));return[...m.map((U)=>{let{run:B,workload:j}=U,z=B.timing,A={task:An(j,B),unit:"ns",samples:z.samples.length,mean:ie(z.mean),median:ie(z.median),stddev:ie(z.stddev),stddevPct:ie(z.mean===0?0:z.stddev/z.mean*100),min:ie(z.min),max:ie(z.max),warnings:[...B.warnings,...C.get(B.workloadId)??[]].map((K)=>K.data?{code:K.code,data:K.data}:{code:K.code})};if(z.p75!==void 0)A.p75=ie(z.p75);if(z.p99!==void 0)A.p99=ie(z.p99);if(z.mad!==void 0)A.mad=ie(z.mad);if(j?.entry?.group!==void 0)A.group=j.entry.group;if(j?.description!==void 0)A.description=j.description;if(j?.groupDescription!==void 0)A.groupDescription=j.groupDescription;if(j?.params!==void 0)A.params=j.params;if(x)A.relative=ie(z.median/(x.get(U)??z.median));if(j?.baseline)A.baseline=!0;let Y=N.get(B.id);if(Y?.timing){if(A.delta={medianPct:ie(Y.timing.medianDeltaPct),meanPct:ie(Y.timing.meanDeltaPct),verdict:Y.timing.verdict,pass:Y.verdict==="pass"},Y.timing.ci95)A.delta.ci95=[ie(Y.timing.ci95[0]),ie(Y.timing.ci95[1])];if(Y.timing.pValue!==void 0)A.delta.pValue=ie(Y.timing.pValue)}return A}),...O]}var nn={name:"minimal",async render(r){let h=_n(r).map((m)=>JSON.stringify(m));return{text:h.length>0?`${h.join(`
|
|
13
|
+
`)}
|
|
14
|
+
`:""}}};var Ln="https://www.speedscope.app/file-format-schema.json";function tn(r){return r?.label??r?.command?.join(" ")??r?.entry?.task??"profile"}var rn={name:"speedscope",async render(r,h={}){let m=pe(r,h.measurementId),x=new Map(r.workloads.map((F)=>[F.id,F]));return{files:m.map((F)=>{let C=F.cpu,{nodes:O}=C,W=fe(C),U=C.samples?.nodeIds??[],B=C.samples?.timeDeltasUs??[],j=Array(W.count);for(let K of W.order){let Z=W.parentIx[K],ee=O[K].frameIx;j[K]=Z===-1?[ee]:[...j[Z],ee]}let z=Array(U.length);for(let K=0;K<U.length;K++){let Z=W.indexOf(U[K]);z[K]=Z===-1?[]:j[Z]}let A=0;for(let K=0;K<B.length;K++)A+=B[K];let Y={$schema:Ln,exporter:"ostia",name:tn(x.get(F.workloadId)),activeProfileIndex:0,shared:{frames:C.frames.map((K)=>({name:K.name||"(anonymous)",file:K.url,line:K.line!==void 0?K.line+1:void 0}))},profiles:[{type:"sampled",name:tn(x.get(F.workloadId)),unit:"microseconds",startValue:0,endValue:A,samples:z,weights:B}]};return{path:`${F.id}.speedscope.json`,content:`${JSON.stringify(Y,null,2)}
|
|
15
|
+
`}})}}};function Vn(r){return(r/1e6).toFixed(3)}function Hn(r){if(r<1024)return`${r.toFixed(0)}B`;if(r<1048576)return`${(r/1024).toFixed(2)}KB`;return`${(r/1048576).toFixed(2)}MB`}function Re(r){return r.label??r.command?.join(" ")??r.entry?.task??r.id}function zn(r){if(!r?.entry)return;if(r.entry.group!==void 0)return r.entry.group;let h=r.entry.task,m=h.lastIndexOf("/");return m===-1?void 0:h.slice(0,m)}var on={name:"table",async render(r){let h=r.measurements.filter((Q)=>Q.phase==="timing"&&Q.timing!==void 0),m=new Map(r.workloads.map((Q)=>[Q.id,Q])),x=r.environment?[Pe(r.environment),""]:[],N=r.workloads.filter((Q)=>Q.skipped&&!h.some((se)=>se.workloadId===Q.id));if(h.length===0&&N.length===0){let Q=sn(r,m);return{text:Q.length>0?`${[...x,...Q].join(`
|
|
16
|
+
`)}
|
|
17
|
+
`:`(no timing runs)
|
|
18
|
+
`}}let F=new Map(h.map((Q)=>[Q.workloadId,Q])),C=[];for(let Q of r.workloads){let se=F.get(Q.id);if(se)C.push({kind:"measured",run:se,workload:Q,label:Re(Q)});else if(Q.skipped)C.push({kind:"skipped",workload:Q,label:Re(Q)})}let O=C.filter((Q)=>Q.kind==="measured"),W=new Map(r.measurements.filter((Q)=>Q.phase==="memstats"&&Q.memory?.bytesPerOp!==void 0).map((Q)=>[Q.workloadId,Q.memory.bytesPerOp])),U=W.size>0,B=O.length>1,j=$e(O),z=new Map,A=new Map,Y;for(let Q of C){let se=zn(Q.workload);if(se!==Y){if(se!==void 0)A.set(Q,se);Y=se}z.set(Q,se!==void 0?" ":"")}let K=Math.max(4,...C.map((Q)=>z.get(Q).length+Q.label.length)),Z=10,ee=18,re=18,X=10,V=[...x],G=U?` ${"Alloc/op".padEnd(X)}`:"",q=`${"Task".padEnd(K)} ${"Median".padEnd(Z)} ${"Spread".padEnd(ee)} ${"Range".padEnd(re)}${G}${B?" Relative":""}`;V.push(q),V.push("-".repeat(q.length));let te=[];for(let Q of C){let se=A.get(Q);if(se!==void 0)V.push(`${se}:`);let me=z.get(Q);if(Q.kind==="skipped"){V.push(`${(me+Q.label).padEnd(K)} - skipped`);continue}let{run:le,label:pn,workload:Me}=Q,ce=le.timing,ge=be(ce.median),ln=ce.p75??ce.median,dn=ce.p99??ce.max,fn=ae(ce.median,ge),gn=`${ae(ln,ge)}\u2026${ae(dn,ge)}`,hn=`${ae(ce.min,ge)}\u2026${ae(ce.max,ge)}`,he=`${(me+pn).padEnd(K)} ${fn.padEnd(Z)} ${gn.padEnd(ee)} ${hn.padEnd(re)}`;if(U){let ue=Me?W.get(Me.id):void 0,bn=ue!==void 0?Hn(ue):"";he+=` ${bn.padEnd(X)}`}if(B){let ue=ce.median/(j.get(Q)??ce.median);if(ue===1)he+=Me?.baseline?" 1.00\xD7 (baseline)":" 1.00\xD7";else if(ue>1)he+=` ${ue.toFixed(2)}\xD7 slower`;else he+=` ${(1/ue).toFixed(2)}\xD7 faster`}if(V.push(he),le.warnings.length>0)V.push(`${" ".repeat(me.length)} ! ${le.warnings.map((ue)=>ue.code).join(", ")}`),te.push(Q)}if(te.length>0){V.push(""),V.push("Warnings:");for(let Q of te)for(let se of Q.run.warnings)V.push(` ${Q.label}: ${se.message}`)}let ne=Gn(r,m);if(ne.length>0)V.push(""),V.push(...ne);let oe=sn(r,m);if(oe.length>0)V.push(""),V.push(...oe);return{text:`${V.map((Q)=>Q.trimEnd()).join(`
|
|
19
|
+
`)}
|
|
20
|
+
`}}};function Kn(r,h,m){let x=r.measurements.find((F)=>F.id===m),N=x?h.get(x.workloadId):h.get(m);return N?Re(N):m}function sn(r,h){if(!r.comparisons||r.comparisons.length===0)return[];let m=[];for(let x of r.comparisons){let N=Kn(r,h,x.candidateMeasurementId),F=x.verdict==="pass"?"\u2713":"\u2717";if(m.push(`${F} ${N}`),x.timing){let C=(O)=>`${O>=0?"+":""}${O.toFixed(1)}%`;if(x.timing.ci95&&x.timing.pValue!==void 0){let O=x.timing.pValue<0.001?"p<0.001":`p=${x.timing.pValue.toFixed(3)}`;m.push(` timing: ${C(x.timing.medianDeltaPct)} median, 95% CI [${C(x.timing.ci95[0])}, ${C(x.timing.ci95[1])}], ${O} (${x.timing.verdict})`)}else m.push(` timing: ${C(x.timing.medianDeltaPct)} median (${x.timing.verdict})`)}if(x.frames)for(let C of x.frames.slice(0,an)){if(Math.abs(C.deltaPct)<0.5)continue;let O=C.deltaPct>0?"+":"";m.push(` frame ${C.name}: ${O}${C.deltaPct.toFixed(1)}% self-time (${(C.baseSelfUs/1000).toFixed(2)}ms -> ${(C.candSelfUs/1000).toFixed(2)}ms)`)}if(x.heapTypes)for(let C of x.heapTypes.slice(0,cn)){if(Math.abs(C.deltaPct)<0.5)continue;let O=C.deltaPct>0?"+":"";m.push(` heap ${C.type}: ${O}${C.deltaPct.toFixed(1)}% count (${C.baseCount} -> ${C.candCount})`)}}return m}var an=5,cn=5;function Gn(r,h){let m=[];for(let x of r.measurements){if(x.phase!=="cpu"&&x.phase!=="heap")continue;let N=h.get(x.workloadId),F=N?Re(N):x.workloadId;if(x.phase==="cpu")if(x.cpu){m.push(`CPU capture - ${F} (instrumented, ${x.cpu.samplingIntervalUs}\xB5s interval, diagnostic wall ${Vn(x.diagnosticWallNs??0)}ms)`);let C=x.cpu.totals.reduce((O,W)=>O+W.selfUs,0)||1;for(let O of x.cpu.totals.slice(0,an)){let W=x.cpu.frames[O.frameIx],U=(O.selfUs/C*100).toFixed(1);m.push(` ${U.padStart(5)}% ${(O.selfUs/1000).toFixed(2).padStart(8)}ms self ${W?.name??"?"}`)}}else m.push(`CPU capture - ${F} (instrumented, no evidence captured)`);else if(x.heap){let C=((x.heap.heapSizeBytes??0)/1e6).toFixed(2);m.push(`Heap snapshot - ${F} (instrumented, ${x.heap.objectCount??"?"} objects, ${C}MB)`);for(let O of x.heap.typeCounts.slice(0,cn))m.push(` ${String(O.count).padStart(6)} ${O.type}`)}else m.push(`Heap snapshot - ${F} (instrumented, no evidence captured)`);for(let C of x.artifacts)m.push(` artifact: ${C.path}`);for(let C of x.warnings)m.push(` ! ${C.message}`)}return m}var s={table:on,json:Ke,markdown:Xe,jsonl:Ge,minimal:nn,collapsed:He,mermaid:Ze,speedscope:rn,cpuprofile:ze};function H(r){return r}var Jn="node_modules/.cache/ostia",De=1000;async function R(r){let h=o({samples:r.samples??null,budgetMs:r.budgetMs??null,minSamples:r.minSamples??null,warmup:r.warmup??null,cpu:r.cpu??!1,heap:r.heap??!1,cpuIntervalUs:r.cpuIntervalUs??De}),x=`${r.outDir??Jn}/artifacts`,N=r.noiseCheck===!1?void 0:f(),F=N?g(N):void 0,C=[],O=[],W=r.commands.map((j)=>{let z=Array.isArray(j)?j:We(j),A=p(z,Array.isArray(j)?void 0:j);return{argv:z,workload:A}}),U=(r.interleave??!0)&&W.length>1,B=(j)=>({argv:j,cwd:r.cwd,env:r.env,samples:r.samples,budgetMs:r.budgetMs,minSamples:r.minSamples,warmup:r.warmup});if(U){let j=W.map(({argv:A})=>Te(B(A)));for(let A of j)await A.warmup();let z=!0;while(z){z=!1;for(let A of j)if(await A.step())z=!0}for(let A=0;A<W.length;A++){let{argv:Y,workload:K}=W[A];C.push(K);let Z=j[A].result(),ee=i({workload:K,configFingerprint:h,trials:Z.trials,timing:Z.timing,warnings:F&&O.length===0?[...Z.warnings,F]:Z.warnings,interleaved:!0});O.push(ee),O.push(...await un(K,Y,ee.id,h,r,x))}return n(C,O,N)}for(let{argv:j,workload:z}of W){C.push(z);let A=await w(B(j)),Y=i({workload:z,configFingerprint:h,trials:A.trials,timing:A.timing,warnings:F&&O.length===0?[...A.warnings,F]:A.warnings});O.push(Y),O.push(...await un(z,j,Y.id,h,r,x))}return n(C,O,N)}async function un(r,h,m,x,N,F){let C=[];if(N.cpu){let O=`${m}-cpu.cpuprofile`,W=await Se({argv:h,cwd:N.cwd,env:N.env,artifactDir:F,fileName:O,intervalUs:N.cpuIntervalUs??De});C.push(await mn({workload:r,phase:"cpu",configFingerprint:x,diagnosticWallNs:W.diagnosticWallNs,exitCode:W.exitCode,cpu:W.cpu,artifactPath:W.artifactPath,artifactKind:"cpuprofile",warnings:W.warnings}))}if(N.heap){let O=`${m}-heap.heapsnapshot`,W=await Fe({argv:h,cwd:N.cwd,env:N.env,artifactDir:F,fileName:O});C.push(await mn({workload:r,phase:"heap",configFingerprint:x,diagnosticWallNs:W.diagnosticWallNs,exitCode:W.exitCode,heap:W.heap,artifactPath:W.artifactPath,artifactKind:"heapsnapshot",warnings:W.warnings}))}return C}async function mn(r){let h=`${r.workload.id}-${r.phase}-${r.configFingerprint}`,m=r.artifactPath?[await S(h,r.artifactKind,r.artifactPath)]:[];return a({workload:r.workload,phase:r.phase,configFingerprint:r.configFingerprint,diagnosticWallNs:r.diagnosticWallNs,exitCode:r.exitCode,cpu:r.cpu,heap:r.heap,warnings:r.warnings,artifacts:m})}async function J(r,h={}){let m=D(r),x=o({intervalUs:h.intervalUs??De,origin:h.origin??"inspector"}),N=(U)=>U.samples?.nodeIds.length===0?[{code:"empty-profile",message:"In-process capture produced zero samples."}]:[];if(h.origin==="jsc"){let{result:U,cpu:B,jit:j,diagnosticWallNs:z}=await d(r,h),A=a({workload:m,phase:"cpu",configFingerprint:x,diagnosticWallNs:z,cpu:B,jit:j,warnings:N(B),artifacts:[]});return{result:U,measurement:A,document:n([m],[A])}}let{result:F,cpu:C,diagnosticWallNs:O}=await Ue(r,h),W=a({workload:m,phase:"cpu",configFingerprint:x,diagnosticWallNs:O,cpu:C,warnings:N(C),artifacts:[]});return{result:F,measurement:W,document:n([m],[W])}}
|
|
21
|
+
export{P,T,I,c,l,b,v,w,_,L,s,H,R,J};
|
package/cli.js
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{
|
|
4
|
-
`)}var
|
|
3
|
+
import{P,T,I,c,l,b,v,w,s,R}from"./chunk-r5b8vf8w.js";import{e,m,n,p,i,o,r,t}from"./chunk-qbt85kmg.js";function G(a){return e("cache",a.workloadId,a.phase,a.configFingerprint,a.bunVersion,a.toolVersion,a.instrumented,a.inputsDigest??null)}async function z(a,u=process.cwd()){if(a.length===0)return;let d=new Set;for(let g of a){let k=new Bun.Glob(g);for await(let y of k.scan({cwd:u,absolute:!1}))d.add(y)}let f=[...d].sort(),h=await Promise.all(f.map(async(g)=>{let k=await Bun.file(`${u}/${g}`).arrayBuffer();return{path:g,sha256:Bun.CryptoHasher.hash("sha256",k,"hex")}}));return e("inputs",h)}function K(a,u){return`${a}/cache/${u}.json`}async function Z(a,u){let d=Bun.file(K(a,u));if(!await d.exists())return;return await d.json()}async function X(a,u,d){await Bun.write(K(a,u),`${JSON.stringify(d,null,2)}
|
|
4
|
+
`)}var le="node_modules/.cache/ostia",ce=".ostia/baselines",ue={runs:null,warmup:3,outDir:le,baselineDir:ce,baseline:"main",cpuIntervalUs:1000,thresholds:l,workloads:[]};function ee(a){return{...ue,...a,thresholds:{...l,...a.thresholds??{}}}}async function Q(a){let u=Bun.file(a);if(!await u.exists())return;return ee(await u.json())}async function Y(a){let u=a.startsWith("/")?a:`${process.cwd()}/${a}`;if(!await Bun.file(u).exists())return;let d=await import(u);return ee(d.default??{})}async function U(a){if(a!==void 0)return a.endsWith(".ts")?Y(a):Q(a);return await Y("ostia.config.ts")??Q("ostia.config.json")}function M(a,u){return`${a.baselineDir}/${u??a.baseline}.json`}class H extends Error{path;constructor(a){super(`No baseline document at ${a}. Create one with: ostia time --export-json ${a} <command...>`);this.path=a}}async function _(a,u){let d=[];for(let f of a.workloads){if(f.suites){let j=await T(f.suites,process.cwd()),A=await c({suites:j,outDir:a.outDir,noiseCheck:!1,budgetMs:a.bench?.budgetMs,samples:a.bench?.samples,minSamples:a.bench?.minSamples,gc:a.bench?.gc,cpu:a.bench?.cpu,alloc:a.bench?.alloc,filter:a.bench?.filter,isolate:a.bench?.isolate,preload:a.bench?.preload,jobs:typeof a.bench?.jobs==="number"?a.bench.jobs:void 0});for(let E of A.workloads){let C=A.measurements.find((B)=>B.workloadId===E.id&&B.phase==="timing");if(!C)continue;d.push({workload:E,status:"executed",run:C})}continue}let h=p(f.command,f.label),g=await z(f.inputs??[]),k=o({runs:a.runs,warmup:a.warmup}),y=G({workloadId:h.id,phase:"timing",configFingerprint:k,bunVersion:Bun.version,toolVersion:m,instrumented:!1,inputsDigest:g}),D=u?void 0:await Z(a.outDir,y),x,N;if(D)x=D,N="cached";else{let j=await w({argv:f.command,samples:a.runs??void 0,warmup:a.warmup});x=i({workload:h,configFingerprint:k,trials:j.trials,timing:j.timing,warnings:j.warnings}),await X(a.outDir,y,x),N="executed"}d.push({workload:h,status:N,run:x})}return d}async function te(a){let{config:u}=a,d=M(u,a.baselineName);if(!await Bun.file(d).exists())throw new H(d);let h=await t(d),k=(await _(u,a.full)).map((C)=>({...C})),y=k.filter((C)=>C.status==="executed").length,D=k.filter((C)=>C.status==="cached").length,x=y,N=n(k.map((C)=>C.workload),k.map((C)=>C.run)),j=0,A=0,E=0;for(let C of k){let B=v(h,N,C.workload.id,u.thresholds);if(!B){E++;continue}if(C.comparison=B,B.verdict==="pass")j++;else A++}return N.comparisons=k.map((C)=>C.comparison).filter((C)=>C!==void 0),{document:N,summary:{total:k.length,affected:y,cached:D,executed:x,passed:j,regressed:A,missingBaseline:E,results:k}}}function se(a){let u=[];if(u.push(`${a.total} workloads`),u.push(`${a.affected} affected by this change`),u.push(`${a.cached} cached`),u.push(`${a.executed} executed`),a.missingBaseline>0)u.push(`${a.missingBaseline} skipped (no matching baseline workload)`);let d=a.results.filter((f)=>f.comparison?.verdict==="fail").map((f)=>{let h=f.comparison.timing,g=f.workload.label??f.workload.command?.join(" ")??f.workload.id;return h?`${h.medianDeltaPct>0?"+":""}${h.medianDeltaPct.toFixed(1)}% median on ${g}`:g});return u.push(`${a.passed} passed ${a.regressed} regressed${d.length>0?` (${d.join(", ")})`:""}`),u.push(""),u.push(`Profile CI: ${a.regressed>0?"\u2717":"\u2713"}`),`${u.join(`
|
|
5
5
|
`)}
|
|
6
|
-
`}async function
|
|
7
|
-
`)}else if(
|
|
8
|
-
${
|
|
9
|
-
`)}var
|
|
6
|
+
`}async function ne(a,u){let d=await _(a,!1),f=n(d.map((g)=>g.workload),d.map((g)=>g.run)),h=M(a,u);return await r(f,h),h}async function re(a){let u=[];try{let f=new Bun.Glob("*.json");for await(let h of f.scan({cwd:a.baselineDir,absolute:!1}))u.push(h.replace(/\.json$/,""))}catch{return[]}u.sort();let d=[];for(let f of u){let h=M(a,f);try{let g=await t(h);d.push({name:f,path:h,createdAt:g.createdAt,toolVersion:g.toolVersion,bunVersion:g.bunVersion,workloads:g.workloads.length,...g.git!==void 0&&{git:g.git}})}catch{}}return d}async function L(a,u){if(a.text)process.stdout.write(a.text);if(!a.files||a.files.length===0)return;if(u)for(let d of a.files){let f=d.path?`${u}/${d.path}`:u;await Bun.write(f,d.content),process.stdout.write(`wrote ${f}
|
|
7
|
+
`)}else if(a.files.length===1)process.stdout.write(a.files[0].content);else for(let d of a.files)process.stdout.write(`--- ${d.path??"(unnamed)"} ---
|
|
8
|
+
${d.content}
|
|
9
|
+
`)}var me=`ostia time [flags] <command...>
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Time one or more commands N times with warmup and report timing statistics.
|
|
12
12
|
|
|
13
13
|
Flags:
|
|
14
|
-
--
|
|
14
|
+
--samples N exact number of timed trials
|
|
15
|
+
--budget MS wall-clock time budget for the sampling loop (default: a
|
|
16
|
+
hyperfine-style ~3s min-total-time loop when neither
|
|
17
|
+
--samples nor --budget is given)
|
|
18
|
+
--min-samples N hard floor on trials when --samples is not given
|
|
15
19
|
--warmup N warmup trials, discarded (default: 3)
|
|
20
|
+
--no-interleave run each command's whole trial loop to completion before the next
|
|
21
|
+
command starts, instead of round-robin (one trial per command,
|
|
22
|
+
repeated). Round-robin is the default with 2+ commands: it spreads
|
|
23
|
+
drift over the run's wall-clock span (thermal throttling, a noisy
|
|
24
|
+
neighbor process) evenly across every command instead of favoring
|
|
25
|
+
whichever ran first or last. Meaningless (and ignored) with one
|
|
26
|
+
command. Interleaved measurements carry Measurement.interleaved: true.
|
|
16
27
|
--cpu capture one instrumented CPU-profile trial (subprocess --cpu-prof)
|
|
17
28
|
--heap capture one instrumented heap-snapshot trial (subprocess --heap-prof)
|
|
18
29
|
--cpu-interval USEC CPU sampling interval in microseconds (default: 1000)
|
|
19
30
|
--out-dir PATH directory for captured artifacts (default: node_modules/.cache/ostia)
|
|
31
|
+
--no-noise-check skip the ~200ms machine noise floor reference measurement
|
|
20
32
|
--export-json PATH write the full ProfileDocument to PATH
|
|
21
33
|
--format FORMAT table | json | jsonl | markdown | minimal (default: table)
|
|
22
34
|
--quiet suppress the rendered report (still writes --export-json)
|
|
@@ -26,17 +38,20 @@ Instrumented runs (--cpu, --heap) are labeled separately from clean timing and n
|
|
|
26
38
|
mixed into the timing statistics.
|
|
27
39
|
|
|
28
40
|
Examples:
|
|
29
|
-
ostia
|
|
30
|
-
ostia
|
|
31
|
-
ostia
|
|
32
|
-
ostia
|
|
33
|
-
|
|
41
|
+
ostia time "bun ./fixtures/work.ts"
|
|
42
|
+
ostia time --samples 25 --warmup 3 "bun a.ts" "bun b.ts"
|
|
43
|
+
ostia time --no-interleave "bun a.ts" "bun b.ts"
|
|
44
|
+
ostia time --cpu --heap "bun src/server.ts"
|
|
45
|
+
ostia time --format json "bun a.ts"
|
|
46
|
+
`,oe=`ostia bench [flags] <suite.ts...>
|
|
34
47
|
|
|
35
48
|
Run in-process benchmark suites (registered via group()/task()). Each suite file runs
|
|
36
49
|
in its own spawned child process (isolated from CLI startup state).
|
|
37
50
|
|
|
38
51
|
Flags:
|
|
39
|
-
--
|
|
52
|
+
--budget MS sampling budget per task; always runs at least this long (default: 500).
|
|
53
|
+
--samples N exact trial count per task; when set, the budget is ignored -
|
|
54
|
+
the in-process equivalent of "ostia time"'s --samples.
|
|
40
55
|
--min-samples N hard floor on samples per task, kept even when it overruns the
|
|
41
56
|
budget. Default: cost-aware - as many as fit in the budget (max 20),
|
|
42
57
|
but never below the floor the task's per-trial cost earns it: 3 at
|
|
@@ -51,6 +66,14 @@ Flags:
|
|
|
51
66
|
like-for-like with a baseline measured at 1. "auto" = CPU count.
|
|
52
67
|
--gc Bun.gc(true) between trials (default: off - hides allocation cost).
|
|
53
68
|
Per-task { gc } / per-group { gc } override this default.
|
|
69
|
+
--cpu capture an extra phase: "cpu" measurement per task (200ms of the
|
|
70
|
+
task looped under the JSC sampling profiler, JIT tiers included) on
|
|
71
|
+
top of its timing numbers. Per-task { cpu } / per-group { cpu }
|
|
72
|
+
override this default. Once captured, "ostia compare" reports
|
|
73
|
+
per-frame CPU deltas the same way it already does for "ostia time --cpu".
|
|
74
|
+
--alloc capture an extra phase: "memstats" measurement per task: bytes
|
|
75
|
+
allocated per call, from a Bun.gc(true)-bracketed batch of 100 calls.
|
|
76
|
+
Per-task { alloc } / per-group { alloc } override this default.
|
|
54
77
|
--filter REGEX only run tasks whose "group/name" id matches this regex (substring,
|
|
55
78
|
case-sensitive; unmatched tasks are skipped, not timed)
|
|
56
79
|
--isolate give every task its own subprocess instead of sharing its suite
|
|
@@ -70,12 +93,13 @@ Flags:
|
|
|
70
93
|
resolution condition Bun doesn't set by default, e.g. Svelte/Vue's
|
|
71
94
|
"browser" vs "default" build: --bun-flags="--conditions=browser"
|
|
72
95
|
--out-dir PATH directory for scratch IPC files (default: node_modules/.cache/ostia)
|
|
96
|
+
--no-noise-check skip the ~200ms machine noise floor reference measurement
|
|
73
97
|
--export-json PATH write the full ProfileDocument to PATH
|
|
74
98
|
--format FORMAT table | json | jsonl | markdown | minimal (default: table)
|
|
75
99
|
"minimal" is one compact JSON object per task with no raw sample
|
|
76
|
-
array: {task, group, description, samples, mean, median,
|
|
77
|
-
relative, warnings[{code,data}]} in ns - built to pipe
|
|
78
|
-
agent's context.
|
|
100
|
+
array: {task, group, description, params, samples, mean, median,
|
|
101
|
+
stddevPct, relative, warnings[{code,data}]} in ns - built to pipe
|
|
102
|
+
into an LLM agent's context.
|
|
79
103
|
--quiet suppress the rendered report (still writes --export-json)
|
|
80
104
|
--help show this message
|
|
81
105
|
|
|
@@ -83,22 +107,33 @@ Suite files register tasks like:
|
|
|
83
107
|
import { group, task } from "<pkg>"
|
|
84
108
|
group("parse", () => {
|
|
85
109
|
task("small input", () => parse(smallBuf))
|
|
86
|
-
task("full pipeline", () => build(), {
|
|
110
|
+
task("full pipeline", () => build(), { budgetMs: 2000, minSamples: 10 })
|
|
87
111
|
}, { description: "parser throughput on representative inputs" })
|
|
88
|
-
Per-task options override --
|
|
89
|
-
only; per-group { gc } / { isolate }
|
|
112
|
+
Per-task options override --budget / --min-samples / --gc / --isolate / --cpu / --alloc
|
|
113
|
+
for that task only; per-group { gc } / { isolate } / { cpu } / { alloc } set the default for
|
|
114
|
+
every task in that group.
|
|
90
115
|
Optional { description } on group() and task() flows into the document (Workload.description
|
|
91
116
|
/ Workload.groupDescription) so the intent travels with the numbers.
|
|
92
117
|
|
|
93
|
-
Sweep
|
|
94
|
-
|
|
95
|
-
|
|
118
|
+
Sweep one or more dimensions with sweep(dims, fn): a cartesian product over the
|
|
119
|
+
dimensions, calling fn once per point. task() calls inside automatically inherit the
|
|
120
|
+
point as Workload.params (an explicit { params } on a task merges over it):
|
|
121
|
+
import { group, task, range, sweep } from "<pkg>"
|
|
96
122
|
group("parse", () => {
|
|
97
|
-
|
|
123
|
+
sweep({ size: range(100, 10_000), impl: ["current", "fast"] }, ({ size, impl }) => {
|
|
98
124
|
const input = buildInput(size) // setup, runs once per point, unmeasured
|
|
99
|
-
task(\`\${
|
|
100
|
-
}
|
|
125
|
+
task(\`\${impl}\`, () => impls[impl](input))
|
|
126
|
+
})
|
|
101
127
|
})
|
|
128
|
+
range(start, end, multiplier?) is the geometric point generator that feeds sweep()
|
|
129
|
+
(mitata's .range(), default multiplier 8, always ending on the end value).
|
|
130
|
+
|
|
131
|
+
task.skip(...) / group.skip(...) register without measuring: the document still
|
|
132
|
+
carries the workload (marked skipped) instead of it being absent, so a renderer
|
|
133
|
+
prints "- skipped" and compare reports it as unchanged with a warning rather than
|
|
134
|
+
silently passing. task.only(...) / group.only(...) restrict the suite file to only
|
|
135
|
+
the selected tasks (--filter still applies on top) and print a one-line notice to
|
|
136
|
+
stderr, so a forgotten .only is visible.
|
|
102
137
|
|
|
103
138
|
Project defaults: with no suite files given on the command line, ostia falls back to
|
|
104
139
|
ostia.config.json's "bench" section in the current directory - suites is a list of globs
|
|
@@ -110,13 +145,14 @@ still works as a one-off override without editing the config.
|
|
|
110
145
|
|
|
111
146
|
Examples:
|
|
112
147
|
ostia bench benches/parse.ts
|
|
113
|
-
ostia bench --
|
|
148
|
+
ostia bench --budget 1000 --min-samples 50 benches/*.ts
|
|
114
149
|
ostia bench benches/*.ts --filter parse
|
|
115
150
|
ostia bench benches/*.ts --jobs auto --format minimal
|
|
151
|
+
ostia bench benches/*.ts --cpu --alloc
|
|
116
152
|
ostia bench --preload ./bench/jsdom-setup.ts benches/*.dom.bench.ts
|
|
117
153
|
ostia bench --bun-flags="--conditions=browser" bench/*.dom.bench.ts
|
|
118
154
|
ostia bench # picks up suites/preload/jobs from ostia.config.json
|
|
119
|
-
`,
|
|
155
|
+
`,ae=`ostia compare <base.json> <candidate.json>
|
|
120
156
|
ostia compare <candidate.json> --baseline <path.json>
|
|
121
157
|
|
|
122
158
|
Compare two ProfileDocuments (matched by workload id) and rank timing/frame/heap deltas.
|
|
@@ -131,31 +167,35 @@ Flags:
|
|
|
131
167
|
Examples:
|
|
132
168
|
ostia compare before.json after.json
|
|
133
169
|
ostia compare after.json --baseline .ostia/baselines/main.json
|
|
134
|
-
`,
|
|
135
|
-
|
|
136
|
-
Render a saved ProfileDocument.
|
|
137
|
-
`,ne=`ostia viz <document.json> --format FORMAT [--run <id>] [--out-dir PATH]
|
|
170
|
+
`,de=`ostia report <document.json> [flags]
|
|
138
171
|
|
|
139
|
-
Render
|
|
140
|
-
|
|
141
|
-
a Mermaid renderer.
|
|
172
|
+
Render a saved ProfileDocument. Files, not a GUI for the visualization formats -
|
|
173
|
+
hand the output to speedscope.app, flamegraph.pl, or a Mermaid renderer.
|
|
142
174
|
|
|
143
175
|
Formats:
|
|
144
|
-
|
|
176
|
+
table terminal timing/CPU/heap/comparison text (default)
|
|
177
|
+
json pretty JSON document
|
|
178
|
+
jsonl one metadata line, then one line per measurement
|
|
179
|
+
markdown agent- and human-readable report
|
|
180
|
+
minimal one compact JSON object per timing measurement, for LLM/CI consumption
|
|
145
181
|
collapsed folded stacks: "root;a;b 42" - flamegraph.pl and most flame tooling
|
|
146
182
|
mermaid call tree, top-15 frames by total time (never the whole profile)
|
|
147
183
|
speedscope sampled profile JSON for speedscope.app
|
|
148
184
|
cpuprofile verbatim .cpuprofile pass-through (cpu-prof/inspector origins only)
|
|
149
185
|
|
|
150
186
|
Flags:
|
|
151
|
-
--
|
|
152
|
-
--
|
|
153
|
-
|
|
187
|
+
--format FORMAT one of the formats above (default: table)
|
|
188
|
+
--measurement <id> for the visualization formats: render only this measurement
|
|
189
|
+
(default: every CPU measurement in the document)
|
|
190
|
+
--out-dir PATH write visualization files here instead of stdout
|
|
191
|
+
--help show this message
|
|
154
192
|
|
|
155
193
|
Examples:
|
|
156
|
-
ostia
|
|
157
|
-
ostia
|
|
158
|
-
|
|
194
|
+
ostia report doc.json
|
|
195
|
+
ostia report doc.json --format markdown
|
|
196
|
+
ostia report doc.json --format speedscope --out-dir node_modules/.cache/ostia/viz
|
|
197
|
+
ostia report doc.json --format collapsed | flamegraph.pl > flame.svg
|
|
198
|
+
`,pe=`ostia ci [--full] [--baseline NAME] [--save-baseline]
|
|
159
199
|
|
|
160
200
|
Load ostia.config.json, run configured workloads (reusing cached results when their
|
|
161
201
|
fingerprint is unchanged), compare against the named baseline, and gate on regressions.
|
|
@@ -163,36 +203,66 @@ fingerprint is unchanged), compare against the named baseline, and gate on regre
|
|
|
163
203
|
Flags:
|
|
164
204
|
--full ignore the cache; rerun every configured workload
|
|
165
205
|
--baseline NAME baseline name (default: config's "baseline" field, or "main")
|
|
206
|
+
--save-baseline after a pass (no regressions), write the just-measured document as
|
|
207
|
+
the new baseline at the same path just compared against - promotes
|
|
208
|
+
today's numbers to tomorrow's floor in one step.
|
|
166
209
|
--export-json PATH write the resulting document (with comparisons) to PATH
|
|
167
210
|
--quiet suppress the rendered report (still writes --export-json)
|
|
168
211
|
--help show this message
|
|
169
212
|
|
|
170
213
|
Exit codes: 0 pass, 1 regression, 2 harness error (missing config/baseline, spawn failure).
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
214
|
+
`,q=`ostia baseline <save|list|show> [args]
|
|
215
|
+
|
|
216
|
+
Manage the baseline ProfileDocuments "ostia ci" gates against and "ostia compare --baseline"
|
|
217
|
+
reads.
|
|
218
|
+
|
|
219
|
+
Subcommands:
|
|
220
|
+
save [name] measure every configured workload (same code path as "ostia ci",
|
|
221
|
+
no comparison) and write it to <baselineDir>/<name>.json
|
|
222
|
+
(default name: config's "baseline" field, or "main")
|
|
223
|
+
list list saved baselines: name, created date, workload count
|
|
224
|
+
show <name> [flags] render a saved baseline; delegates to "ostia report" (same
|
|
225
|
+
--format/--measurement/--out-dir flags)
|
|
226
|
+
|
|
227
|
+
Examples:
|
|
228
|
+
ostia baseline save
|
|
229
|
+
ostia baseline save my-feature
|
|
230
|
+
ostia baseline list
|
|
231
|
+
ostia baseline show main
|
|
232
|
+
ostia baseline show main --format markdown
|
|
233
|
+
`;function fe(a){let u=[],d,f,h,g,k=!0,y=!1,D=!1,x,N,j=!0,A,E="table",C=!1,B=!1;for(let F=0;F<a.length;F++){let J=a[F];switch(J){case"--samples":d=Number(a[++F]);break;case"--budget":f=Number(a[++F]);break;case"--min-samples":h=Number(a[++F]);break;case"--warmup":g=Number(a[++F]);break;case"--no-interleave":k=!1;break;case"--cpu":y=!0;break;case"--heap":D=!0;break;case"--cpu-interval":x=Number(a[++F]);break;case"--out-dir":N=a[++F];break;case"--no-noise-check":j=!1;break;case"--export-json":A=a[++F];break;case"--format":E=a[++F];break;case"--quiet":C=!0;break;case"--help":case"-h":B=!0;break;default:u.push(J)}}return{commands:u,samples:d,budgetMs:f,minSamples:h,warmup:g,interleave:k,cpu:y,heap:D,cpuIntervalUs:x,outDir:N,noiseCheck:j,exportJson:A,format:E,quiet:C,help:B}}async function he(a){let u=fe(a);if(u.help||u.commands.length===0)return process.stdout.write(me),u.help?0:2;if(!(u.format in s))return process.stderr.write(`Unknown --format "${u.format}". Expected one of: ${Object.keys(s).join(", ")}
|
|
234
|
+
`),2;let d;try{d=await R({commands:u.commands,samples:u.samples,budgetMs:u.budgetMs,minSamples:u.minSamples,warmup:u.warmup,interleave:u.interleave,cpu:u.cpu,heap:u.heap,cpuIntervalUs:u.cpuIntervalUs,outDir:u.outDir,noiseCheck:u.noiseCheck})}catch(h){return process.stderr.write(`Run failed: ${h instanceof Error?h.message:String(h)}
|
|
235
|
+
`),2}if(u.exportJson)await r(d,u.exportJson);if(!u.quiet){let g=await s[u.format].render(d,{});await L(g)}return d.measurements.some((h)=>h.trials.some((g)=>g.exitCode!==void 0&&g.exitCode!==0))?1:0}function be(a){let u=[],d,f,h,g,k=!1,y=!1,D=!1,x,N=!1,j=[],A=[],E,C=!0,B,F="table",J=!1,V=!1;for(let S=0;S<a.length;S++){let O=a[S];if(O==="--bun-flags"||O.startsWith("--bun-flags=")){let W=O.startsWith("--bun-flags=")?O.slice(12):a[++S]??"";A.push(...W.split(/\s+/).filter(Boolean));continue}switch(O){case"--budget":d=Number(a[++S]);break;case"--samples":f=Number(a[++S]);break;case"--min-samples":h=Number(a[++S]);break;case"--jobs":{let W=a[++S];g=W==="auto"?P():Number(W);break}case"--gc":k=!0;break;case"--cpu":y=!0;break;case"--alloc":D=!0;break;case"--filter":x=a[++S];break;case"--isolate":N=!0;break;case"--preload":j.push(a[++S]);break;case"--out-dir":E=a[++S];break;case"--no-noise-check":C=!1;break;case"--export-json":B=a[++S];break;case"--format":F=a[++S];break;case"--quiet":J=!0;break;case"--help":case"-h":V=!0;break;default:u.push(O)}}return{suites:u,budgetMs:d,samples:f,minSamples:h,jobs:g,gc:k,cpu:y,alloc:D,filter:x,isolate:N,preload:j,bunFlags:A,outDir:E,noiseCheck:C,exportJson:B,format:F,quiet:J,help:V}}async function ge(a){let u=be(a);if(u.help)return process.stdout.write(oe),0;if(!(u.format in s))return process.stderr.write(`Unknown --format "${u.format}". Expected one of: ${Object.keys(s).join(", ")}
|
|
236
|
+
`),2;let d=await U(),f=await I(u,d?.bench);if(f.suites.length===0)return process.stdout.write(oe),2;if(f.jobs!==void 0&&!(f.jobs>=1))return process.stderr.write(`--jobs expects a positive integer or "auto".
|
|
237
|
+
`),2;let h;try{h=await c(f)}catch(g){return process.stderr.write(`Bench failed: ${g instanceof Error?g.message:String(g)}
|
|
238
|
+
`),2}if(u.exportJson)await r(h,u.exportJson);if(!u.quiet){let k=await s[u.format].render(h,{});await L(k)}return 0}function we(a){let u=[],d,f,h="table",g=!1,k=!1;for(let y=0;y<a.length;y++){let D=a[y];switch(D){case"--baseline":d=a[++y];break;case"--export-json":f=a[++y];break;case"--format":h=a[++y];break;case"--quiet":g=!0;break;case"--help":case"-h":k=!0;break;default:u.push(D)}}return{paths:u,baseline:d,exportJson:f,format:h,quiet:g,help:k}}async function ke(a){let u=we(a);if(u.help)return process.stdout.write(ae),0;let d,f;if(u.baseline)d=u.baseline,f=u.paths[0];else d=u.paths[0],f=u.paths[1];if(!d||!f)return process.stdout.write(ae),2;let h,g;try{[h,g]=await Promise.all([t(d),t(f)])}catch(x){return process.stderr.write(`Failed to load documents: ${x instanceof Error?x.message:String(x)}
|
|
239
|
+
`),2}let k=b(h,g),y={...g,comparisons:k};if(u.exportJson)await r(y,u.exportJson);if(!u.quiet){if(h.git&&g.git){let j=(A)=>`${A.sha} (${A.branch}${A.dirty?", dirty":""})`;process.stdout.write(`base ${j(h.git)} \u2192 cand ${j(g.git)}
|
|
240
|
+
`)}let N=await s[u.format].render(y,{});await L(N)}return k.some((x)=>x.verdict==="fail")?1:0}function ye(a){let u,d="table",f,h,g=!1;for(let k=0;k<a.length;k++){let y=a[k];switch(y){case"--format":d=a[++k]??"";break;case"--measurement":f=a[++k];break;case"--out-dir":h=a[++k];break;case"--help":case"-h":g=!0;break;default:u=y}}return{path:u,format:d,measurementId:f,outDir:h,help:g}}async function ie(a){let u=ye(a);if(u.help||!u.path)return process.stdout.write(de),u.help?0:2;if(!(u.format in s))return process.stderr.write(`Unknown --format "${u.format}". Expected one of: ${Object.keys(s).join(", ")}
|
|
241
|
+
`),2;let d;try{d=await t(u.path)}catch(g){return process.stderr.write(`Failed to load ${u.path}: ${g instanceof Error?g.message:String(g)}
|
|
242
|
+
`),2}let h=await s[u.format].render(d,{measurementId:u.measurementId});if(!h.text&&(!h.files||h.files.length===0))return process.stderr.write(u.measurementId?`No CPU evidence found for measurement "${u.measurementId}".
|
|
243
|
+
`:`No CPU evidence found in this document (no cpu-phase measurements). Capture some with "ostia time --cpu ...".
|
|
244
|
+
`),2;return await L(h,u.outDir),0}function Ce(a){let u=!1,d,f=!1,h,g=!1,k=!1;for(let y=0;y<a.length;y++)switch(a[y]){case"--full":u=!0;break;case"--baseline":d=a[++y];break;case"--save-baseline":f=!0;break;case"--export-json":h=a[++y];break;case"--quiet":g=!0;break;case"--help":case"-h":k=!0;break}return{full:u,baseline:d,saveBaseline:f,exportJson:h,quiet:g,help:k}}async function xe(a){let u=Ce(a);if(u.help)return process.stdout.write(pe),0;let d=await U();if(!d)return process.stderr.write(`No ostia.config.json found. "ostia ci" needs configured workloads.
|
|
245
|
+
`),2;if(d.workloads.length===0)return process.stderr.write(`ostia.config.json has no "workloads" configured.
|
|
246
|
+
`),2;let f;try{f=await te({config:d,full:u.full,baselineName:u.baseline})}catch(h){if(h instanceof H)return process.stderr.write(`${h.message}
|
|
185
247
|
`),2;return process.stderr.write(`CI run failed: ${h instanceof Error?h.message:String(h)}
|
|
186
|
-
`),2}if(
|
|
248
|
+
`),2}if(u.exportJson)await r(f.document,u.exportJson);if(u.saveBaseline&&f.summary.regressed===0)await r(f.document,M(d,u.baseline));if(!u.quiet)process.stdout.write(se(f.summary));return f.summary.regressed>0?1:0}async function Pe(a){if(a.includes("--help")||a.includes("-h"))return process.stdout.write(q),0;let u=a[0],d=await U();if(!d)return process.stderr.write(`No ostia.config.json found. "ostia baseline save" needs configured workloads.
|
|
249
|
+
`),2;if(d.workloads.length===0)return process.stderr.write(`ostia.config.json has no "workloads" configured.
|
|
250
|
+
`),2;let f=await ne(d,u);return process.stdout.write(`Wrote ${f}
|
|
251
|
+
`),0}async function je(a){if(a.includes("--help")||a.includes("-h"))return process.stdout.write(q),0;let u=await U();if(!u)return process.stderr.write(`No ostia.config.json found.
|
|
252
|
+
`),2;let d=await re(u);if(d.length===0)return process.stdout.write(`No baselines found in ${u.baselineDir}.
|
|
253
|
+
`),0;for(let f of d){let h=f.git?` ${f.git.sha} (${f.git.branch}${f.git.dirty?", dirty":""})`:"";process.stdout.write(`${f.name} ${f.workloads} workloads created ${f.createdAt} toolVersion ${f.toolVersion}${h}
|
|
254
|
+
`)}return 0}async function ve(a){let[u,...d]=a;if(!u||u==="--help"||u==="-h")return process.stdout.write(q),u?0:2;let f=await U();if(!f)return process.stderr.write(`No ostia.config.json found.
|
|
255
|
+
`),2;return ie([M(f,u),...d])}async function De(a){let[u,...d]=a;switch(u){case"save":return Pe(d);case"list":return je(d);case"show":return ve(d);case void 0:case"--help":case"-h":return process.stdout.write(q),u===void 0?2:0;default:return process.stderr.write(`Unknown "ostia baseline ${u}". Run "ostia baseline --help".
|
|
256
|
+
`),2}}async function $e(){let[a,...u]=process.argv.slice(2);switch(a){case"time":return he(u);case"bench":return ge(u);case"compare":return ke(u);case"report":return ie(u);case"ci":return xe(u);case"baseline":return De(u);case void 0:case"--help":case"-h":return process.stdout.write(`ostia - Bun-native profile IR engine
|
|
187
257
|
|
|
188
258
|
Commands:
|
|
189
|
-
|
|
259
|
+
time Time commands N times and report timing/CPU/heap
|
|
190
260
|
bench Run in-process benchmark suites (group()/task())
|
|
191
261
|
compare Compare two ProfileDocuments
|
|
192
|
-
report Render a saved ProfileDocument
|
|
262
|
+
report Render a saved ProfileDocument (table/json/markdown/collapsed/mermaid/speedscope/...)
|
|
193
263
|
ci Run configured workloads against a baseline, gate on regressions
|
|
194
|
-
|
|
264
|
+
baseline Manage baseline ProfileDocuments (save/list/show)
|
|
195
265
|
|
|
196
266
|
Run "ostia <command> --help" for details.
|
|
197
|
-
`),
|
|
198
|
-
`),2}}if(import.meta.main)
|
|
267
|
+
`),a===void 0?2:0;default:return process.stderr.write(`Unknown subcommand "${a}". Run "ostia --help".
|
|
268
|
+
`),2}}if(import.meta.main)$e().then((a)=>process.exit(a));
|