Comparing version
@@ -49,3 +49,3 @@ /** | ||
/** | ||
* run the current task and write the results in `Task.result` object property | ||
* run the current task and write the results in `Task.result` object property (sync version) | ||
* @returns the current task | ||
@@ -501,2 +501,6 @@ * @internal | ||
run(): Promise<Task[]>; | ||
/** | ||
* run the added tasks that were registered using the {@link add} method (sync version) | ||
* @returns the tasks array | ||
*/ | ||
runSync(): Task[]; | ||
@@ -503,0 +507,0 @@ /** |
var c1 = Object.defineProperty; | ||
var q = (e) => { | ||
var $ = (e) => { | ||
throw TypeError(e); | ||
}; | ||
var h1 = (e, s, t) => s in e ? c1(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t; | ||
var M = (e, s, t) => h1(e, typeof s != "symbol" ? s + "" : s, t), K = (e, s, t) => s.has(e) || q("Cannot " + t); | ||
var f = (e, s, t) => (K(e, s, "read from private field"), t ? t.call(e) : s.get(e)), F = (e, s, t) => s.has(e) ? q("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(e) : s.set(e, t), b = (e, s, t, n) => (K(e, s, "write to private field"), n ? n.call(e, t) : s.set(e, t), t); | ||
var l1 = (e, s, t) => s in e ? c1(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t; | ||
var F = (e, s, t) => l1(e, typeof s != "symbol" ? s + "" : s, t), z = (e, s, t) => s.has(e) || $("Cannot " + t); | ||
var d = (e, s, t) => (z(e, s, "read from private field"), t ? t.call(e) : s.get(e)), O = (e, s, t) => s.has(e) ? $("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(e) : s.set(e, t), b = (e, s, t, n) => (z(e, s, "write to private field"), n ? n.call(e, t) : s.set(e, t), t); | ||
var P = (e, s, t, n) => ({ | ||
@@ -13,3 +13,3 @@ set _(r) { | ||
get _() { | ||
return f(e, s, n); | ||
return d(e, s, n); | ||
} | ||
@@ -21,11 +21,11 @@ }); | ||
constructor(s) { | ||
M(this, "value"); | ||
M(this, "next"); | ||
F(this, "value"); | ||
F(this, "next"); | ||
this.value = s; | ||
} | ||
}, p, v, w, E = class { | ||
}, p, g, w, E = class { | ||
constructor() { | ||
F(this, p); | ||
F(this, v); | ||
F(this, w); | ||
O(this, p); | ||
O(this, g); | ||
O(this, w); | ||
this.clear(); | ||
@@ -35,21 +35,21 @@ } | ||
let t = new B(s); | ||
f(this, p) ? (f(this, v).next = t, b(this, v, t)) : (b(this, p, t), b(this, v, t)), P(this, w)._++; | ||
d(this, p) ? (d(this, g).next = t, b(this, g, t)) : (b(this, p, t), b(this, g, t)), P(this, w)._++; | ||
} | ||
dequeue() { | ||
let s = f(this, p); | ||
let s = d(this, p); | ||
if (s) | ||
return b(this, p, f(this, p).next), P(this, w)._--, s.value; | ||
return b(this, p, d(this, p).next), P(this, w)._--, s.value; | ||
} | ||
peek() { | ||
if (f(this, p)) | ||
return f(this, p).value; | ||
if (d(this, p)) | ||
return d(this, p).value; | ||
} | ||
clear() { | ||
b(this, p, void 0), b(this, v, void 0), b(this, w, 0); | ||
b(this, p, void 0), b(this, g, void 0), b(this, w, 0); | ||
} | ||
get size() { | ||
return f(this, w); | ||
return d(this, w); | ||
} | ||
*[Symbol.iterator]() { | ||
let s = f(this, p); | ||
let s = d(this, p); | ||
for (; s; ) | ||
@@ -59,7 +59,7 @@ yield s.value, s = s.next; | ||
}; | ||
p = new WeakMap(), v = new WeakMap(), w = new WeakMap(); | ||
p = new WeakMap(), g = new WeakMap(), w = new WeakMap(); | ||
// node_modules/.pnpm/p-limit@6.2.0/node_modules/p-limit/index.js | ||
function k(e) { | ||
z(e); | ||
C(e); | ||
let s = new E(), t = 0, n = () => { | ||
@@ -69,18 +69,18 @@ t < e && s.size > 0 && (s.dequeue()(), t++); | ||
t--, n(); | ||
}, a = async (h, i, c) => { | ||
let g = (async () => h(...c))(); | ||
i(g); | ||
}, a = async (c, i, h) => { | ||
let v = (async () => c(...h))(); | ||
i(v); | ||
try { | ||
await g; | ||
} catch (L1) { | ||
await v; | ||
} catch (P1) { | ||
} | ||
r(); | ||
}, o = (h, i, c) => { | ||
new Promise((g) => { | ||
s.enqueue(g); | ||
}, o = (c, i, h) => { | ||
new Promise((v) => { | ||
s.enqueue(v); | ||
}).then( | ||
a.bind(void 0, h, i, c) | ||
a.bind(void 0, c, i, h) | ||
), (async () => (await Promise.resolve(), t < e && n()))(); | ||
}, u = (h, ...i) => new Promise((c) => { | ||
o(h, c, i); | ||
}, u = (c, ...i) => new Promise((h) => { | ||
o(c, h, i); | ||
}); | ||
@@ -101,4 +101,4 @@ return Object.defineProperties(u, { | ||
get: () => e, | ||
set(h) { | ||
z(h), e = h, queueMicrotask(() => { | ||
set(c) { | ||
C(c), e = c, queueMicrotask(() => { | ||
for (; t < e && s.size > 0; ) | ||
@@ -111,3 +111,3 @@ n(); | ||
} | ||
function z(e) { | ||
function C(e) { | ||
if (!((Number.isInteger(e) || e === Number.POSITIVE_INFINITY) && e > 0)) | ||
@@ -1144,3 +1144,3 @@ throw new TypeError("Expected `concurrency` to be a number from 1 and up"); | ||
infinity: 1.96 | ||
}), C = 1e3, V = 64, W = 250, D = 16, T = Object.freeze(() => { | ||
}), V = 1e3, W = 64, D = 250, H = 16, T = Object.freeze(() => { | ||
}); | ||
@@ -1157,3 +1157,3 @@ | ||
}), t; | ||
}, x = (e, s) => { | ||
}, S = (e, s) => { | ||
let t = new Event("error"); | ||
@@ -1174,6 +1174,6 @@ return Object.defineProperty(t, "task", { | ||
// src/utils.ts | ||
var Y, G, l1 = !!globalThis.Bun || !!((G = (Y = globalThis.process) == null ? void 0 : Y.versions) != null && G.bun), m1 = !!globalThis.Deno, U, X, p1 = ((X = (U = globalThis.process) == null ? void 0 : U.release) == null ? void 0 : X.name) === "node", d1 = !!globalThis.HermesInternal, Z, f1 = ( | ||
var Y, G, m1 = !!globalThis.Bun || !!((G = (Y = globalThis.process) == null ? void 0 : Y.versions) != null && G.bun), p1 = !!globalThis.Deno, U, X, f1 = ((X = (U = globalThis.process) == null ? void 0 : U.release) == null ? void 0 : X.name) === "node", d1 = !!globalThis.HermesInternal, Z, b1 = ( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access | ||
((Z = globalThis.navigator) == null ? void 0 : Z.userAgent) === "Cloudflare-Workers" | ||
), t1, A, e1, L, n1, b1 = !!((n1 = (L = (e1 = (A = (t1 = globalThis.navigator) == null ? void 0 : t1.userAgent) == null ? void 0 : A.toLowerCase) == null ? void 0 : e1.call(A)) == null ? void 0 : L.includes) != null && n1.call(L, "quickjs-ng")), y1 = typeof globalThis.Netlify == "object", g1 = typeof globalThis.EdgeRuntime == "string", v1 = !!globalThis.__lagon__, w1 = !!globalThis.fastly, k1 = ( | ||
), t1, A, e1, M, n1, y1 = !!((n1 = (M = (e1 = (A = (t1 = globalThis.navigator) == null ? void 0 : t1.userAgent) == null ? void 0 : A.toLowerCase) == null ? void 0 : e1.call(A)) == null ? void 0 : M.includes) != null && n1.call(M, "quickjs-ng")), v1 = typeof globalThis.Netlify == "object", g1 = typeof globalThis.EdgeRuntime == "string", w1 = !!globalThis.__lagon__, k1 = !!globalThis.fastly, T1 = ( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access | ||
@@ -1183,23 +1183,23 @@ !!globalThis.$262 && // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access | ||
!!globalThis.AsyncDisposableStack | ||
), T1 = !!globalThis.d8, s1, E1 = ( | ||
), E1 = !!globalThis.d8, s1, S1 = ( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access | ||
!!globalThis.inIon && !!((s1 = globalThis.performance) != null && s1.mozMemory) | ||
), x1 = ( | ||
), R1 = ( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access | ||
!!globalThis.$ && // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @cspell/spellchecker | ||
"IsHTMLDDA" in globalThis.$ | ||
), S1 = ( | ||
), x1 = ( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access | ||
!!globalThis.window && !!globalThis.navigator | ||
), y = l1 ? "bun" : m1 ? "deno" : p1 ? "node" : d1 ? "hermes" : y1 ? "netlify" : g1 ? "edge-light" : v1 ? "lagon" : w1 ? "fastly" : f1 ? "workerd" : b1 ? "quickjs-ng" : k1 ? "moddable" : T1 ? "v8" : E1 ? "spidermonkey" : x1 ? "jsc" : S1 ? "browser" : "unknown", o1 = (() => { | ||
var e, s, t, n, r, a, o, u, h, i, c, g; | ||
), y = m1 ? "bun" : p1 ? "deno" : f1 ? "node" : d1 ? "hermes" : v1 ? "netlify" : g1 ? "edge-light" : w1 ? "lagon" : k1 ? "fastly" : b1 ? "workerd" : y1 ? "quickjs-ng" : T1 ? "moddable" : E1 ? "v8" : S1 ? "spidermonkey" : R1 ? "jsc" : x1 ? "browser" : "unknown", o1 = (() => { | ||
var e, s, t, n, r, a, o, u, c, i, h, v; | ||
return y === "bun" ? (e = globalThis.Bun) == null ? void 0 : e.version : y === "deno" ? (t = (s = globalThis.Deno) == null ? void 0 : s.version) == null ? void 0 : t.deno : y === "node" ? (r = (n = globalThis.process) == null ? void 0 : n.versions) == null ? void 0 : r.node : y === "hermes" ? (u = (o = (a = globalThis.HermesInternal) == null ? void 0 : a.getRuntimeProperties) == null ? void 0 : o.call(a)) == null ? void 0 : u[ | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
"OSS Release Version" | ||
] : y === "v8" ? (h = globalThis.version) == null ? void 0 : h.call(globalThis) : y === "quickjs-ng" ? (g = (c = (i = globalThis.navigator) == null ? void 0 : i.userAgent) == null ? void 0 : c.split) == null ? void 0 : g.call(c, "/")[1] : "unknown"; | ||
})(), a1 = (e) => e / 1e6, R = (e) => e * 1e6, _, r1, i1; | ||
] : y === "v8" ? (c = globalThis.version) == null ? void 0 : c.call(globalThis) : y === "quickjs-ng" ? (v = (h = (i = globalThis.navigator) == null ? void 0 : i.userAgent) == null ? void 0 : h.split) == null ? void 0 : v.call(h, "/")[1] : "unknown"; | ||
})(), a1 = (e) => e / 1e6, L = (e) => e * 1e6, j = (e, s, t) => Math.abs(e) >= 10 ** s ? e.toFixed() : Math.abs(e) < 10 ** (s - t) ? e.toFixed(t) : e.toPrecision(s), _, r1, i1; | ||
typeof ((i1 = (r1 = globalThis.process) == null ? void 0 : r1.hrtime) == null ? void 0 : i1.bigint) == "function" ? _ = globalThis.process.hrtime.bigint.bind(process.hrtime) : _ = () => { | ||
throw new Error("hrtime.bigint() is not supported in this JS environment"); | ||
}; | ||
var R1 = () => a1(Number(_())), O1 = performance.now.bind(performance), j = O1, d = (e) => e !== null && typeof e == "object" && typeof e.then == "function", F1 = (e) => ( | ||
var O1 = () => a1(Number(_())), A1 = performance.now.bind(performance), J = A1, f = (e) => e !== null && typeof e == "object" && typeof e.then == "function", M1 = (e) => ( | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
@@ -1212,6 +1212,6 @@ (e == null ? void 0 : e.constructor) === (async () => { | ||
return !1; | ||
if (F1(e)) | ||
if (M1(e)) | ||
return !0; | ||
try { | ||
let t = e(), n = d(t); | ||
let t = e(), n = f(t); | ||
if (n) | ||
@@ -1230,3 +1230,3 @@ try { | ||
return e.reduce((s, t) => s + t, 0) / e.length || 0; | ||
}, A1 = (e, s = N(e)) => e.reduce((n, r) => n + (r - s) ** 2, 0) / (e.length - 1) || 0, S = (e, s) => { | ||
}, L1 = (e, s = N(e)) => e.reduce((n, r) => n + (r - s) ** 2, 0) / (e.length - 1) || 0, R = (e, s) => { | ||
if (e.length === 0) | ||
@@ -1246,3 +1246,3 @@ throw new Error("samples must not be empty"); | ||
) : e[n]; | ||
}, H = (e) => S(e, 0.5), Q = (e, s, t = s(e)) => { | ||
}, h1 = (e) => R(e, 0.5), F1 = (e) => h1(e.sort((s, t) => s - t)), Q = (e, s, t = s(e)) => { | ||
let n = []; | ||
@@ -1252,4 +1252,4 @@ for (let r of e) | ||
return s(n); | ||
}, $ = (e) => { | ||
let s = N(e), t = A1(e, s), n = Math.sqrt(t), r = n / Math.sqrt(e.length), a = e.length - 1, o = I[(Math.round(a) || 1).toString()] || I.infinity, u = r * o, h = u / s * 100, i = H(e); | ||
}, q = (e) => { | ||
let s = N(e), t = L1(e, s), n = Math.sqrt(t), r = n / Math.sqrt(e.length), a = e.length - 1, o = I[(Math.round(a) || 1).toString()] || I.infinity, u = r * o, c = u / s * 100, i = h1(e); | ||
return { | ||
@@ -1259,3 +1259,3 @@ aad: Q(e, N, s), | ||
df: a, | ||
mad: Q(e, H, i), | ||
mad: Q(e, F1, i), | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
@@ -1268,7 +1268,7 @@ max: e[a], | ||
p50: i, | ||
p75: S(e, 0.75), | ||
p99: S(e, 0.99), | ||
p995: S(e, 0.995), | ||
p999: S(e, 0.999), | ||
rme: h, | ||
p75: R(e, 0.75), | ||
p99: R(e, 0.99), | ||
p995: R(e, 0.995), | ||
p999: R(e, 0.999), | ||
rme: c, | ||
samples: e, | ||
@@ -1285,3 +1285,3 @@ sd: n, | ||
// src/task.ts | ||
var O = class extends EventTarget { | ||
var x = class extends EventTarget { | ||
constructor(t, n, r, a = {}) { | ||
@@ -1314,3 +1314,3 @@ super(); | ||
async run() { | ||
var r, a, o, u, h; | ||
var r, a, o, u, c; | ||
if ((r = this.result) != null && r.error) | ||
@@ -1325,6 +1325,6 @@ return this; | ||
); | ||
return await ((h = (u = this.bench.opts).teardown) == null ? void 0 : h.call(u, this, "run")), this.processRunResult({ error: t, latencySamples: n }), this; | ||
return await ((c = (u = this.bench.opts).teardown) == null ? void 0 : c.call(u, this, "run")), this.processRunResult({ error: t, latencySamples: n }), this; | ||
} | ||
/** | ||
* run the current task and write the results in `Task.result` object property | ||
* run the current task and write the results in `Task.result` object property (sync version) | ||
* @returns the current task | ||
@@ -1334,3 +1334,3 @@ * @internal | ||
runSync() { | ||
var o, u, h, i, c; | ||
var o, u, c, i, h; | ||
if ((o = this.result) != null && o.error) | ||
@@ -1342,5 +1342,5 @@ return this; | ||
), this.dispatchEvent(l("start", this)); | ||
let t = (h = (u = this.bench.opts).setup) == null ? void 0 : h.call(u, this, "run"); | ||
let t = (c = (u = this.bench.opts).setup) == null ? void 0 : c.call(u, this, "run"); | ||
m( | ||
!d(t), | ||
!f(t), | ||
"`setup` function must be sync when using `runSync()`" | ||
@@ -1353,5 +1353,5 @@ ); | ||
this.bench.opts.iterations | ||
), a = (c = (i = this.bench.opts).teardown) == null ? void 0 : c.call(i, this, "run"); | ||
), a = (h = (i = this.bench.opts).teardown) == null ? void 0 : h.call(i, this, "run"); | ||
return m( | ||
!d(a), | ||
!f(a), | ||
"`teardown` function must be sync when using `runSync()`" | ||
@@ -1382,3 +1382,3 @@ ), this.processRunResult({ error: n, latencySamples: r }), this; | ||
warmupSync() { | ||
var a, o, u, h, i; | ||
var a, o, u, c, i; | ||
if ((a = this.result) != null && a.error) | ||
@@ -1389,3 +1389,3 @@ return; | ||
m( | ||
!d(t), | ||
!f(t), | ||
"`setup` function must be sync when using `runSync()`" | ||
@@ -1398,5 +1398,5 @@ ); | ||
this.bench.opts.warmupIterations | ||
), r = (i = (h = this.bench.opts).teardown) == null ? void 0 : i.call(h, this, "warmup"); | ||
), r = (i = (c = this.bench.opts).teardown) == null ? void 0 : i.call(c, this, "warmup"); | ||
m( | ||
!d(r), | ||
!f(r), | ||
"`teardown` function must be sync when using `runSync()`" | ||
@@ -1406,3 +1406,3 @@ ), this.postWarmup(n); | ||
async benchmark(t, n) { | ||
var u, h; | ||
var u, c; | ||
if (this.fnOpts.beforeAll != null) | ||
@@ -1418,7 +1418,7 @@ try { | ||
if (this.async) { | ||
let c = this.bench.opts.now(); | ||
await this.fn.call(this), i = this.bench.opts.now() - c; | ||
let h = this.bench.opts.now(); | ||
await this.fn.call(this), i = this.bench.opts.now() - h; | ||
} else { | ||
let c = this.bench.opts.now(); | ||
this.fn.call(this), i = this.bench.opts.now() - c; | ||
let h = this.bench.opts.now(); | ||
this.fn.call(this), i = this.bench.opts.now() - h; | ||
} | ||
@@ -1428,3 +1428,3 @@ a.push(i), r += i, this.fnOpts.afterEach != null && await this.fnOpts.afterEach.call(this); | ||
try { | ||
let i = k(this.bench.threshold), c = []; | ||
let i = k(this.bench.threshold), h = []; | ||
for ( | ||
@@ -1435,4 +1435,4 @@ ; | ||
) | ||
this.bench.concurrency === "task" ? c.push(i(o)) : await o(); | ||
!((h = this.bench.opts.signal) != null && h.aborted) && c.length > 0 && await Promise.all(c); | ||
this.bench.concurrency === "task" ? h.push(i(o)) : await o(); | ||
!((c = this.bench.opts.signal) != null && c.aborted) && h.length > 0 && await Promise.all(h); | ||
} catch (i) { | ||
@@ -1454,3 +1454,3 @@ return { error: i }; | ||
m( | ||
!d(u), | ||
!f(u), | ||
"`beforeAll` function must be sync when using `runSync()`" | ||
@@ -1463,16 +1463,16 @@ ); | ||
if (this.fnOpts.beforeEach != null) { | ||
let c = this.fnOpts.beforeEach.call(this); | ||
let h = this.fnOpts.beforeEach.call(this); | ||
m( | ||
!d(c), | ||
!f(h), | ||
"`beforeEach` function must be sync when using `runSync()`" | ||
); | ||
} | ||
let u = 0, h = this.bench.opts.now(), i = this.fn.call(this); | ||
if (u = this.bench.opts.now() - h, m( | ||
!d(i), | ||
let u = 0, c = this.bench.opts.now(), i = this.fn.call(this); | ||
if (u = this.bench.opts.now() - c, m( | ||
!f(i), | ||
"task function must be sync when using `runSync()`" | ||
), a.push(u), r += u, this.fnOpts.afterEach != null) { | ||
let c = this.fnOpts.afterEach.call(this); | ||
let h = this.fnOpts.afterEach.call(this); | ||
m( | ||
!d(c), | ||
!f(h), | ||
"`afterEach` function must be sync when using `runSync()`" | ||
@@ -1496,3 +1496,3 @@ ); | ||
m( | ||
!d(u), | ||
!f(u), | ||
"`afterAll` function must be sync when using `runSync()`" | ||
@@ -1516,3 +1516,3 @@ ); | ||
postWarmup(t) { | ||
if (t && (this.mergeTaskResult({ error: t }), this.dispatchEvent(x(this, t)), this.bench.dispatchEvent(x(this, t)), this.bench.opts.throws)) | ||
if (t && (this.mergeTaskResult({ error: t }), this.dispatchEvent(S(this, t)), this.bench.dispatchEvent(S(this, t)), this.bench.opts.throws)) | ||
throw t; | ||
@@ -1527,7 +1527,7 @@ } | ||
this.runs = n.length; | ||
let a = n.reduce((i, c) => i + c, 0), o = $( | ||
n.sort((i, c) => i - c) | ||
let a = n.reduce((i, h) => i + h, 0), o = q( | ||
n.sort((i, h) => i - h) | ||
), u = n.map( | ||
(i) => i !== 0 ? 1e3 / i : 1e3 / o.mean | ||
).sort((i, c) => i - c), h = $(u); | ||
).sort((i, h) => i - h), c = q(u); | ||
if ((r = this.bench.opts.signal) != null && r.aborted) | ||
@@ -1538,3 +1538,3 @@ return; | ||
df: o.df, | ||
hz: h.mean, | ||
hz: c.mean, | ||
latency: o, | ||
@@ -1556,3 +1556,3 @@ max: o.max, | ||
sem: o.sem, | ||
throughput: h, | ||
throughput: c, | ||
totalTime: a, | ||
@@ -1562,3 +1562,3 @@ variance: o.variance | ||
} | ||
if (t && (this.mergeTaskResult({ error: t }), this.dispatchEvent(x(this, t)), this.bench.dispatchEvent(x(this, t)), this.bench.opts.throws)) | ||
if (t && (this.mergeTaskResult({ error: t }), this.dispatchEvent(S(this, t)), this.bench.dispatchEvent(S(this, t)), this.bench.opts.throws)) | ||
throw t; | ||
@@ -1570,3 +1570,3 @@ this.dispatchEvent(l("cycle", this)), this.bench.dispatchEvent(l("cycle", this)), this.dispatchEvent(l("complete", this)); | ||
// src/bench.ts | ||
var J = class extends EventTarget { | ||
var K = class extends EventTarget { | ||
constructor(t = {}) { | ||
@@ -1591,11 +1591,11 @@ super(); | ||
this.name = t.name, delete t.name, this.runtime = y, this.runtimeVersion = o1, this.opts = { | ||
iterations: V, | ||
now: j, | ||
iterations: W, | ||
now: J, | ||
setup: T, | ||
teardown: T, | ||
throws: !1, | ||
time: C, | ||
time: V, | ||
warmup: !0, | ||
warmupIterations: D, | ||
warmupTime: W, | ||
warmupIterations: H, | ||
warmupTime: D, | ||
...t | ||
@@ -1636,3 +1636,3 @@ }, this.opts.signal && this.opts.signal.addEventListener( | ||
{ | ||
let a = new O(this, t, n, r); | ||
let a = new x(this, t, n, r); | ||
this._tasks.set(t, a), this.dispatchEvent(l("add", a)); | ||
@@ -1690,2 +1690,6 @@ } | ||
} | ||
/** | ||
* run the added tasks that were registered using the {@link add} method (sync version) | ||
* @returns the tasks array | ||
*/ | ||
runSync() { | ||
@@ -1716,8 +1720,8 @@ m( | ||
"Task name": n.name, | ||
"Latency average (ns)": `${R(n.result.latency.mean).toFixed(2)} \xB1 ${n.result.latency.rme.toFixed(2)}%`, | ||
"Latency avg (ns)": `${j(L(n.result.latency.mean), 5, 2)} \xB1 ${n.result.latency.rme.toFixed(2)}%`, | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
"Latency median (ns)": `${R(n.result.latency.p50).toFixed(2)}${Number.parseFloat(R(n.result.latency.mad).toFixed(2)) > 0 ? ` \xB1 ${R(n.result.latency.mad).toFixed(2)}` : ""}`, | ||
"Throughput average (ops/s)": `${n.result.throughput.mean.toFixed(0)} \xB1 ${n.result.throughput.rme.toFixed(2)}%`, | ||
"Latency med (ns)": `${j(L(n.result.latency.p50), 5, 2)} \xB1 ${L(n.result.latency.mad).toFixed(2)}`, | ||
"Throughput avg (ops/s)": `${Math.round(n.result.throughput.mean).toString()} \xB1 ${n.result.throughput.rme.toFixed(2)}%`, | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
"Throughput median (ops/s)": `${n.result.throughput.p50.toFixed(0)}${Number.parseInt(n.result.throughput.mad.toFixed(0), 10) > 0 ? ` \xB1 ${n.result.throughput.mad.toFixed(0)}` : ""}`, | ||
"Throughput med (ops/s)": `${Math.round(n.result.throughput.p50).toString()} \xB1 ${Math.round(n.result.throughput.mad).toString()}`, | ||
Samples: n.result.latency.samples.length | ||
@@ -1750,7 +1754,7 @@ } : null; | ||
export { | ||
J as Bench, | ||
O as Task, | ||
R1 as hrtimeNow, | ||
K as Bench, | ||
x as Task, | ||
O1 as hrtimeNow, | ||
a1 as nToMs, | ||
j as now | ||
J as now | ||
}; |
{ | ||
"name": "tinybench", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"type": "module", | ||
"volta": { | ||
"node": "22.12.0", | ||
"pnpm": "9.15.1" | ||
"node": "22.13.1", | ||
"pnpm": "9.15.4" | ||
}, | ||
@@ -9,0 +9,0 @@ "engines": { |
@@ -51,8 +51,8 @@ # Tinybench 🔎 | ||
// simple benchmark | ||
// ┌─────────┬───────────────┬────────────────────────────┬───────────────────────────┬──────────────────────┬─────────────────────┬─────────┐ | ||
// │ (index) │ Task name │ Throughput average (ops/s) │ Throughput median (ops/s) │ Latency average (ns) │ Latency median (ns) │ Samples │ | ||
// ├─────────┼───────────────┼────────────────────────────┼───────────────────────────┼──────────────────────┼─────────────────────┼─────────┤ | ||
// │ 0 │ 'faster task' │ '102906 ± 0.89%' │ '82217 ± 14' │ '11909.14 ± 3.95%' │ '12163.00 ± 2.00' │ 8398 │ | ||
// │ 1 │ 'slower task' │ '988 ± 26.26%' │ '710' │ '1379560.47 ± 6.72%' │ '1408552.00' │ 73 │ | ||
// └─────────┴───────────────┴────────────────────────────┴───────────────────────────┴──────────────────────┴─────────────────────┴─────────┘ | ||
// ┌─────────┬───────────────┬───────────────────┬───────────────────────┬────────────────────────┬────────────────────────┬─────────┐ | ||
// │ (index) │ Task name │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │ | ||
// ├─────────┼───────────────┼───────────────────┼───────────────────────┼────────────────────────┼────────────────────────┼─────────┤ | ||
// │ 0 │ 'faster task' │ '63768 ± 4.02%' │ '58954 ± 15255.00' │ '18562 ± 1.67%' │ '16962 ± 4849' │ 1569 │ | ||
// │ 1 │ 'slower task' │ '1542543 ± 7.14%' │ '1652502 ± 167851.00' │ '808 ± 19.65%' │ '605 ± 67' │ 65 │ | ||
// └─────────┴───────────────┴───────────────────┴───────────────────────┴────────────────────────┴────────────────────────┴─────────┘ | ||
``` | ||
@@ -59,0 +59,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
138519
0.43%3964
0.3%