Comparing version 0.4.6 to 0.4.8
@@ -34,4 +34,4 @@ var d1=Object.defineProperty;var r=(u,w)=>{for(var N in w)d1(u,N,{get:w[N],enumerable:!0,configurable:!0,set:(d)=>w[N]=()=>d})};var N1=(u,w)=>()=>(u&&(w=u(u=0)),w);var C={};r(C,{uptime:()=>{{return Z1}},type:()=>{{return C1}},totalmem:()=>{{return _1}},tmpdir:()=>{{return x1}},release:()=>{{return G1}},platform:()=>{{return q1}},networkInterfaces:()=>{{return F1}},loadavg:()=>{{return Y1}},hostname:()=>{{return Q1}},homedir:()=>{{return z1}},getNetworkInterfaces:()=>{{return A1}},freemem:()=>{{return B1}},endianness:()=>{{return K1}},default:()=>{{return J1}},cpus:()=>{{return f1}},arch:()=>{{return j1}},EOL:()=>{{return R1}}});var V1,p,U1,X1,T1,W1,D1,I1,P1,H1,n,J1,K1,Q1,Y1,Z1,B1,_1,f1,C1,G1,j1,q1,x1,R1,z1,F1,A1;var G=N1(()=>{V1=Object.create,p=Object.defineProperty,U1=Object.getOwnPropertyDescriptor,X1=Object.getOwnPropertyNames,T1=Object.getPrototypeOf,W1=Object.prototype.hasOwnProperty,D1=(u,w)=>()=>(w||u((w={exports:{}}).exports,w),w.exports),I1=(u,w,N,d)=>{if(w&&typeof w=="object"||typeof w=="function")for(let S of X1(w))!W1.call(u,S)&&S!==N&&p(u,S,{get:()=>w[S],enumerable:!(d=U1(w,S))||d.enumerable});return u},P1=(u,w,N)=>(N=u!=null?V1(T1(u)):{},I1(w||!u||!u.__esModule?p(N,"default",{value:u,enumerable:!0}):N,u)),H1=D1((u)=>{u.endianness=function(){return"LE"},u.hostname=function(){return typeof location<"u"?location.hostname:""},u.loadavg=function(){return[]},u.uptime=function(){return 0},u.freemem=function(){return Number.MAX_VALUE},u.totalmem=function(){return Number.MAX_VALUE},u.cpus=function(){return[]},u.type=function(){return"Browser"},u.release=function(){return typeof navigator<"u"?navigator.appVersion:""},u.networkInterfaces=u.getNetworkInterfaces=function(){return{}},u.arch=function(){return"javascript"},u.platform=function(){return"browser"},u.tmpdir=u.tmpDir=function(){return"/tmp"},u.EOL=` | ||
1 ms = 1 millisecond = 1'000\u03BCs = 1'000'000ns = 1e-9ps = 1e-3s | ||
`)}function L1({size:u,avg:w=!0,iter:N=!0,rmoe:d=!0,min_max:S=!0,percentiles:L=!0}){return`${"benchmark".padEnd(u," ")}${!w?"":"time (avg)".padStart(14," ")}${!N?"":"iter/s".padStart(14," ")}${!d?"":"error margin".padStart(14," ")}${!S?"":"(min \u2026 max)".padStart(24," ")}${!L?"":` ${"p50".padStart(9," ")} ${"p75".padStart(9," ")} ${"p99".padStart(9," ")} ${"p995".padStart(9," ")}`}`}function b(u,w,{size:N,avg:d=!0,iter:S=!0,colors:L=!0,rmoe:M=!0,min_max:E=!0,percentiles:H=!0}){return`${u.padEnd(N," ")}${!d?"":`${B(L,W(w.avg))}/iter`.padStart(14+10*L," ")}${!S?"":`${B(L,s(w.iter))}`.padStart(14+10*L," ")}${!M?"":`\xB1 ${B(L,u1(w.rmoe))}`.padStart(14+10*L," ")}${!E?"":`(${_(L,W(w.min))} \u2026 ${g(L,W(w.max))})`.padStart(24+20*L," ")}${!H?"":` ${V(L,W(w.p50)).padStart(9+10*L," ")} ${V(L,W(w.p75)).padStart(9+10*L," ")} ${V(L,W(w.p99)).padStart(9+10*L," ")} ${V(L,W(w.p995)).padStart(9+10*L," ")}`}${!w.ss?` ${x(L,"!")}`:""}`}function i(u,{colors:w=!0}){u=u.filter((d)=>d.error==null),u.sort((d,S)=>d.stats.avg-S.stats.avg);const N=u.find((d)=>d.baseline)??u[0];return`${`${Z(w,"summary")}${N.group==null||N.group.startsWith(P)?"":V(w,` for ${N.group}`)}`}\n ${Z(w,_(w,N.name))}${u.filter((d)=>d!==N).map((d)=>{const S=d.stats.avg/N.stats.avg;return`\n ${R[1>S?"red":"green"](w,1>S?h(1/S):h(S))}x ${1>S?"slower":"faster"} than ${Z(w,_(w,d.name))}`}).join("")}`}function Nu(u,w=void 0){if(u!=null&&typeof u!=="string"&&Object.prototype.toString.call(u).slice(8,-1)!=="Object"&&![Function,v].includes(u.constructor))throw new TypeError(`expected string, object or function, got ${u.constructor.name}`);if([Function,v].includes(u.constructor))w=u;if(![Function,v].includes(w.constructor))throw new TypeError(`expected function, got ${w.constructor.name}`);if(Object.prototype.toString.call(u).slice(8,-1)==="Object"){if(u.name!=null&&typeof u.name!=="string")throw new TypeError(`expected string as 'name' option, got ${u.name.constructor.name}`);if(u.summary!=null&&typeof u.summary!=="boolean")throw new TypeError(`expected boolean as 'summary' option, got ${u.summary.constructor.name}`);if(u.before!=null&&![Function,v].includes(u.before.constructor))throw new TypeError(`expected function as 'before' option, got ${u.before.constructor.name}`);if(u.after!=null&&![Function,v].includes(u.after.constructor))throw new TypeError(`expected function as 'after' option, got ${u.after.constructor.name}`)}if(D=(typeof u==="string"?u.trim():u.name?.trim())||`${P}${f.size+1}`,!f.has(D))f.set(D,{summary:u.summary??!0,before:u.before??U,after:u.after??U});if(v===w.constructor)w().then(()=>{D=null});else w(),D=null}function Su(u,w=void 0,N={}){if([Function,v].includes(u.constructor))w=u,u=w.name;A(w,N),u=u.trim(),X.push({before:N.before??U,fn:w,after:N.after??U,name:u,group:D,time:Q,samples:Y,warmup:!0,baseline:!1,async:v===w.constructor})}function Eu(u,w=void 0,N={}){if([Function,v].includes(u.constructor))w=u,u=w.name;A(w,N),u=u.trim(),X.push({before:N.before??U,fn:w,after:N.after??U,name:u,group:D,time:Q,samples:Y,warmup:!0,baseline:!0,async:v===w.constructor})}function Mu(){f.clear(),X.length=0}async function Ou(u={}){if(Object.prototype.toString.call(u).slice(8,-1)!=="Object")throw new TypeError(`expected object, got ${u.constructor.name}`);if(u.samples!=null&&typeof u.samples!=="number")throw new TypeError(`expected number as 'samples' option, got ${u.samples.constructor.name}`);if(u.time!=null&&typeof u.time!=="number")throw new TypeError(`expected number as 'time' option, got ${u.time.constructor.name}`);if(u.warmup!=null&&typeof u.warmup!=="boolean")throw new TypeError(`expected boolean as 'warmup' option, got ${u.warmup.constructor.name}`);if(u.json!=null&&typeof u.json!=="number"&&typeof u.json!=="boolean"&&typeof u.json!=="string")throw new TypeError(`expected number or boolean or string as 'json' option, got ${u.json.constructor.name}`);u=q({silent:!1,colors:!o,size:w1(X.map((L)=>L.name))},u);const w=u.silent===!0?U:a,N={benchmarks:X,cpu:t,runtime:`${T} ${e} (${m})`};if(!u.json&&X.length>0)w(V(u.colors,`cpu: ${N.cpu}`)),w(V(u.colors,`runtime: ${N.runtime}`)),w(""),w(L1(u)),w(k(u));let d=!1,S=!1;for(let L of X){if(L.group)continue;if(L.baseline)d=!0;L.samples=u.samples??L.samples,L.time=u.time??L.time,L.warmup=u.warmup??L.warmup,S=!0;try{if(L.stats=await y(L.fn,L.before,L.after,{async:L.async,samples:L.samples,time:L.time,warmup:L.warmup}),!u.json)w(b(L.name,L.stats,u))}catch(M){if(L.error=M,!u.json)w(l(L.name,L.error,u))}}if(d&&!u.json)w(""),w(i(X.filter((L)=>L.group==null),u));for(let[L,M]of f){if(!u.json){if(S)w("");if(!L.startsWith(P))w(`\u2022 ${L}`);if(S||!L.startsWith(P))w(V(u.colors,k(u)))}v===M.before.constructor?await M.before():M.before();for(let E of X){if(L!==E.group)continue;E.samples=u.samples??E.samples,E.time=u.time??E.time,S=!0;try{if(E.stats=await y(E.fn,E.before,E.after,{async:E.async,samples:E.samples,time:E.time,warmup:E.warmup}),!u.json)w(b(E.name,E.stats,u))}catch(H){if(E.error=H,!u.json)w(l(E.name,E.error,u))}}if(v===M.after.constructor?await M.after():M.after(),M.summary===!0&&!u.json)w(""),w(i(X.filter((E)=>L===E.group),u))}if(!u.json&&u.units)w($1(u));if(typeof u.json==="boolean"||typeof u.json==="number")w(JSON.stringify(N,void 0,typeof u.json!=="number"?0:u.json));else if(typeof u.json==="string"){let L;switch(u.json){case"bmf":L=N.benchmarks.map(({name:M,stats:E})=>{return{[M]:{latency:{value:E?.avg,lower_value:E?.min,upper_value:E?.max},throughput:{value:E?.iter}}}}).reduce((M,E)=>Object.assign(M,E),{}),w(JSON.stringify(L));break;default:throw new Error(`unexpected 'json' option: ${u.json}`)}}return N}var D=null,f=new Map,X=[];export{Ou as run,Nu as group,Mu as clear,Su as bench,Eu as baseline}; | ||
`)}function L1({size:u,avg:w=!0,iter:N=!0,rmoe:d=!0,min_max:S=!0,percentiles:L=!0}){return`${"benchmark".padEnd(u," ")}${!w?"":"time (avg)".padStart(14," ")}${!N?"":"iter/s".padStart(14," ")}${!d?"":"error margin".padStart(14," ")}${!S?"":"(min \u2026 max)".padStart(24," ")}${!L?"":` ${"p50".padStart(9," ")} ${"p75".padStart(9," ")} ${"p99".padStart(9," ")} ${"p995".padStart(9," ")}`}`}function b(u,w,{size:N,avg:d=!0,iter:S=!0,colors:L=!0,rmoe:M=!0,min_max:E=!0,percentiles:H=!0}){return`${u.padEnd(N," ")}${!d?"":`${B(L,W(w.avg))}/iter`.padStart(14+10*L," ")}${!S?"":`${B(L,s(w.iter))}`.padStart(14+10*L," ")}${!M?"":`\xB1 ${B(L,u1(w.rmoe))}`.padStart(14+10*L," ")}${!E?"":`(${_(L,W(w.min))} \u2026 ${g(L,W(w.max))})`.padStart(24+20*L," ")}${!H?"":` ${V(L,W(w.p50)).padStart(9+10*L," ")} ${V(L,W(w.p75)).padStart(9+10*L," ")} ${V(L,W(w.p99)).padStart(9+10*L," ")} ${V(L,W(w.p995)).padStart(9+10*L," ")}`}${!w.ss?` ${x(L,"!")}`:""}`}function i(u,{colors:w=!0}){u=u.filter((d)=>d.error==null),u.sort((d,S)=>d.stats.avg-S.stats.avg);const N=u.find((d)=>d.baseline)??u[0];return`${`${Z(w,"summary")}${N.group==null||N.group.startsWith(P)?"":V(w,` for ${N.group}`)}`}\n ${Z(w,_(w,N.name))}${u.filter((d)=>d!==N).map((d)=>{const S=d.stats.avg/N.stats.avg;return`\n ${R[1>S?"red":"green"](w,1>S?h(1/S):h(S))}x ${1>S?"slower":"faster"} than ${Z(w,_(w,d.name))}`}).join("")}`}function Nu(u,w=void 0){if(u!=null&&typeof u!=="string"&&Object.prototype.toString.call(u).slice(8,-1)!=="Object"&&![Function,v].includes(u.constructor))throw new TypeError(`expected string, object or function, got ${u.constructor.name}`);if([Function,v].includes(u.constructor))w=u;if(![Function,v].includes(w.constructor))throw new TypeError(`expected function, got ${w.constructor.name}`);if(Object.prototype.toString.call(u).slice(8,-1)==="Object"){if(u.name!=null&&typeof u.name!=="string")throw new TypeError(`expected string as 'name' option, got ${u.name.constructor.name}`);if(u.summary!=null&&typeof u.summary!=="boolean")throw new TypeError(`expected boolean as 'summary' option, got ${u.summary.constructor.name}`);if(u.before!=null&&![Function,v].includes(u.before.constructor))throw new TypeError(`expected function as 'before' option, got ${u.before.constructor.name}`);if(u.after!=null&&![Function,v].includes(u.after.constructor))throw new TypeError(`expected function as 'after' option, got ${u.after.constructor.name}`)}if(D=(typeof u==="string"?u.trim():u.name?.trim())||`${P}${f.size+1}`,!f.has(D))f.set(D,{summary:u.summary??!0,before:u.before??U,after:u.after??U});if(v===w.constructor)w().then(()=>{D=null});else w(),D=null}function Su(u,w=void 0,N={}){if([Function,v].includes(u.constructor))w=u,u=w.name;A(w,N),u=u.trim(),X.push({before:N.before??U,fn:w,after:N.after??U,name:u,group:D,time:Q,samples:Y,warmup:!0,baseline:!1,async:v===w.constructor})}function Eu(u,w=void 0,N={}){if([Function,v].includes(u.constructor))w=u,u=w.name;A(w,N),u=u.trim(),X.push({before:N.before??U,fn:w,after:N.after??U,name:u,group:D,time:Q,samples:Y,warmup:!0,baseline:!0,async:v===w.constructor})}function Mu(){f.clear(),X.length=0}async function Ou(u={}){if(Object.prototype.toString.call(u).slice(8,-1)!=="Object")throw new TypeError(`expected object, got ${u.constructor.name}`);if(u.samples!=null&&typeof u.samples!=="number")throw new TypeError(`expected number as 'samples' option, got ${u.samples.constructor.name}`);if(u.time!=null&&typeof u.time!=="number")throw new TypeError(`expected number as 'time' option, got ${u.time.constructor.name}`);if(u.warmup!=null&&typeof u.warmup!=="boolean")throw new TypeError(`expected boolean as 'warmup' option, got ${u.warmup.constructor.name}`);if(u.json!=null&&typeof u.json!=="number"&&typeof u.json!=="boolean"&&typeof u.json!=="string")throw new TypeError(`expected number or boolean or string as 'json' option, got ${u.json.constructor.name}`);u=q({silent:!1,colors:!o,size:w1(X.map((L)=>L.name))},u);const w=u.silent===!0?U:a,N={benchmarks:X,cpu:t,runtime:`${T} ${e} (${m})`};if(!u.json&&X.length>0)w(V(u.colors,`cpu: ${N.cpu}`)),w(V(u.colors,`runtime: ${N.runtime}`)),w(""),w(L1(u)),w(k(u));let d=!1,S=!1;for(let L of X){if(L.group)continue;if(L.baseline)d=!0;L.samples=u.samples??L.samples,L.time=u.time??L.time,L.warmup=u.warmup??L.warmup,S=!0;try{if(L.stats=await y(L.fn,L.before,L.after,{async:L.async,samples:L.samples,time:L.time,warmup:L.warmup}),!u.json)w(b(L.name,L.stats,u))}catch(M){if(L.error=M,!u.json)w(l(L.name,L.error,u))}}if(d&&!u.json)w(""),w(i(X.filter((L)=>L.group==null),u));for(let[L,M]of f){if(!u.json){if(S)w("");if(!L.startsWith(P))w(`\u2022 ${L}`);if(S||!L.startsWith(P))w(V(u.colors,k(u)))}v===M.before.constructor?await M.before():M.before();for(let E of X){if(L!==E.group)continue;E.samples=u.samples??E.samples,E.time=u.time??E.time,S=!0;try{if(E.stats=await y(E.fn,E.before,E.after,{async:E.async,samples:E.samples,time:E.time,warmup:E.warmup}),!u.json)w(b(E.name,E.stats,u))}catch(H){if(E.error=H,!u.json)w(l(E.name,E.error,u))}}if(v===M.after.constructor?await M.after():M.after(),M.summary===!0&&!u.json)w(""),w(i(X.filter((E)=>L===E.group),u))}if(!u.json&&u.units)w($1(u));if((typeof u.json==="boolean"||typeof u.json==="number")&&u.json)w(JSON.stringify(N,void 0,typeof u.json!=="number"?0:u.json));else if(typeof u.json==="string"){let L;switch(u.json){case"bmf":L=N.benchmarks.map(({name:M,stats:E})=>{return{[M]:{latency:{value:E?.avg,lower_value:E?.min,upper_value:E?.max},throughput:{value:E?.iter}}}}).reduce((M,E)=>Object.assign(M,E),{}),w(JSON.stringify(L));break;default:throw new Error(`unexpected 'json' option: ${u.json}`)}}return JSON.parse(JSON.stringify(N))}var D=null,f=new Map,X=[];export{Ou as run,Nu as group,Mu as clear,Su as bench,Eu as baseline}; | ||
//# debugId=5567395AE93CF0D364756e2164756e21 | ||
//# debugId=4CEA001416FDBBA864756e2164756e21 |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "0.4.6", | ||
"version": "0.4.8", | ||
"packageManager": "bun@1.1.8", | ||
@@ -9,0 +9,0 @@ "types": "./src/index.d.ts", |
@@ -75,3 +75,3 @@ <h1 align=center>tatami-ng</h1> | ||
... | ||
} from 'https://cdn.jsdelivr.net/npm/tatami-ng@0.4.6/dist/browser/index.js' | ||
} from 'https://cdn.jsdelivr.net/npm/tatami-ng@0.4.8/dist/browser/index.js' | ||
</script> | ||
@@ -78,0 +78,0 @@ ``` |
@@ -356,3 +356,6 @@ import { | ||
if (!opts.json && opts.units) log(table.units(opts)); | ||
if ('boolean' === typeof opts.json || 'number' === typeof opts.json) { | ||
if ( | ||
('boolean' === typeof opts.json || 'number' === typeof opts.json) && | ||
opts.json | ||
) { | ||
log( | ||
@@ -392,3 +395,3 @@ JSON.stringify( | ||
return report; | ||
return JSON.parse(JSON.stringify(report)); | ||
} |
@@ -71,5 +71,2 @@ export function group(cb: () => void | Promise<void>): void; | ||
warmup: boolean; | ||
before: () => void | Promise<void>; | ||
fn: () => void | Promise<void>; | ||
after: () => void | Promise<void>; | ||
async: boolean; | ||
@@ -76,0 +73,0 @@ baseline: boolean; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
187847