overtake 1.4.0 → 2.0.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 +4 -15
- package/bin/overtake.js +1 -1
- package/build/executor.d.ts +7 -3
- package/build/index.d.ts +10 -11
- package/build/reporter.d.ts +10 -2
- package/build/runner.d.ts +1 -1
- package/build/types.d.ts +6 -6
- package/build/utils.d.ts +1 -17
- package/package.json +8 -26
- package/src/__tests__/assert-no-closure.ts +135 -0
- package/src/__tests__/benchmark-execute.ts +48 -0
- package/src/cli.ts +139 -144
- package/src/executor.ts +48 -18
- package/src/index.ts +85 -57
- package/src/reporter.ts +27 -19
- package/src/runner.ts +2 -5
- package/src/types.ts +8 -8
- package/src/utils.ts +15 -54
- package/src/worker.ts +6 -3
- package/tsconfig.json +3 -1
- package/build/cli.cjs +0 -179
- package/build/cli.cjs.map +0 -1
- package/build/cli.js +0 -134
- package/build/cli.js.map +0 -1
- package/build/executor.cjs +0 -123
- package/build/executor.cjs.map +0 -1
- package/build/executor.js +0 -113
- package/build/executor.js.map +0 -1
- package/build/gc-watcher.cjs +0 -30
- package/build/gc-watcher.cjs.map +0 -1
- package/build/gc-watcher.js +0 -20
- package/build/gc-watcher.js.map +0 -1
- package/build/index.cjs +0 -442
- package/build/index.cjs.map +0 -1
- package/build/index.js +0 -377
- package/build/index.js.map +0 -1
- package/build/reporter.cjs +0 -311
- package/build/reporter.cjs.map +0 -1
- package/build/reporter.js +0 -293
- package/build/reporter.js.map +0 -1
- package/build/runner.cjs +0 -532
- package/build/runner.cjs.map +0 -1
- package/build/runner.js +0 -522
- package/build/runner.js.map +0 -1
- package/build/types.cjs +0 -66
- package/build/types.cjs.map +0 -1
- package/build/types.js +0 -33
- package/build/types.js.map +0 -1
- package/build/utils.cjs +0 -174
- package/build/utils.cjs.map +0 -1
- package/build/utils.js +0 -132
- package/build/utils.js.map +0 -1
- package/build/worker.cjs +0 -155
- package/build/worker.cjs.map +0 -1
- package/build/worker.js +0 -110
- package/build/worker.js.map +0 -1
- package/src/__tests__/assert-no-closure.js +0 -134
package/build/index.cjs
DELETED
|
@@ -1,442 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get AsyncFunction () {
|
|
13
|
-
return AsyncFunction;
|
|
14
|
-
},
|
|
15
|
-
get Benchmark () {
|
|
16
|
-
return Benchmark;
|
|
17
|
-
},
|
|
18
|
-
get DEFAULT_REPORT_TYPES () {
|
|
19
|
-
return DEFAULT_REPORT_TYPES;
|
|
20
|
-
},
|
|
21
|
-
get DEFAULT_WORKERS () {
|
|
22
|
-
return DEFAULT_WORKERS;
|
|
23
|
-
},
|
|
24
|
-
get FeedContext () {
|
|
25
|
-
return FeedContext;
|
|
26
|
-
},
|
|
27
|
-
get Measure () {
|
|
28
|
-
return Measure;
|
|
29
|
-
},
|
|
30
|
-
get MeasureContext () {
|
|
31
|
-
return MeasureContext;
|
|
32
|
-
},
|
|
33
|
-
get Target () {
|
|
34
|
-
return Target;
|
|
35
|
-
},
|
|
36
|
-
get TargetContext () {
|
|
37
|
-
return TargetContext;
|
|
38
|
-
},
|
|
39
|
-
get printComparisonReports () {
|
|
40
|
-
return printComparisonReports;
|
|
41
|
-
},
|
|
42
|
-
get printHistogramReports () {
|
|
43
|
-
return printHistogramReports;
|
|
44
|
-
},
|
|
45
|
-
get printJSONReports () {
|
|
46
|
-
return printJSONReports;
|
|
47
|
-
},
|
|
48
|
-
get printMarkdownReports () {
|
|
49
|
-
return printMarkdownReports;
|
|
50
|
-
},
|
|
51
|
-
get printSimpleReports () {
|
|
52
|
-
return printSimpleReports;
|
|
53
|
-
},
|
|
54
|
-
get printTableReports () {
|
|
55
|
-
return printTableReports;
|
|
56
|
-
},
|
|
57
|
-
get reportsToBaseline () {
|
|
58
|
-
return reportsToBaseline;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
const _nodeos = require("node:os");
|
|
62
|
-
const _progress = /*#__PURE__*/ _interop_require_default(require("progress"));
|
|
63
|
-
const _executorcjs = require("./executor.cjs");
|
|
64
|
-
const _typescjs = require("./types.cjs");
|
|
65
|
-
function _interop_require_default(obj) {
|
|
66
|
-
return obj && obj.__esModule ? obj : {
|
|
67
|
-
default: obj
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
const DEFAULT_WORKERS = Math.max(1, Math.ceil((0, _nodeos.cpus)().length / 4));
|
|
71
|
-
const AsyncFunction = (async ()=>{}).constructor;
|
|
72
|
-
const BENCHMARK_URL = Symbol.for('overtake.benchmarkUrl');
|
|
73
|
-
const DEFAULT_REPORT_TYPES = [
|
|
74
|
-
'ops'
|
|
75
|
-
];
|
|
76
|
-
class MeasureContext {
|
|
77
|
-
title;
|
|
78
|
-
run;
|
|
79
|
-
pre;
|
|
80
|
-
post;
|
|
81
|
-
constructor(title, run){
|
|
82
|
-
this.title = title;
|
|
83
|
-
this.run = run;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
class Measure {
|
|
87
|
-
#ctx;
|
|
88
|
-
constructor(ctx){
|
|
89
|
-
this.#ctx = ctx;
|
|
90
|
-
}
|
|
91
|
-
pre(fn) {
|
|
92
|
-
this.#ctx.pre = fn;
|
|
93
|
-
return this;
|
|
94
|
-
}
|
|
95
|
-
post(fn) {
|
|
96
|
-
this.#ctx.post = fn;
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
class TargetContext {
|
|
101
|
-
title;
|
|
102
|
-
setup;
|
|
103
|
-
teardown;
|
|
104
|
-
measures = [];
|
|
105
|
-
constructor(title, setup){
|
|
106
|
-
this.title = title;
|
|
107
|
-
this.setup = setup;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
class Target {
|
|
111
|
-
#ctx;
|
|
112
|
-
constructor(ctx){
|
|
113
|
-
this.#ctx = ctx;
|
|
114
|
-
}
|
|
115
|
-
teardown(fn) {
|
|
116
|
-
this.#ctx.teardown = fn;
|
|
117
|
-
return this;
|
|
118
|
-
}
|
|
119
|
-
measure(title, run) {
|
|
120
|
-
const measure = new MeasureContext(title, run);
|
|
121
|
-
this.#ctx.measures.push(measure);
|
|
122
|
-
return new Measure(measure);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
class FeedContext {
|
|
126
|
-
title;
|
|
127
|
-
fn;
|
|
128
|
-
constructor(title, fn){
|
|
129
|
-
this.title = title;
|
|
130
|
-
this.fn = fn;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
class Benchmark {
|
|
134
|
-
#targets = [];
|
|
135
|
-
#feeds = [];
|
|
136
|
-
#executed = false;
|
|
137
|
-
static create(title, fn) {
|
|
138
|
-
if (fn) {
|
|
139
|
-
return new Benchmark(title, fn);
|
|
140
|
-
} else {
|
|
141
|
-
return new Benchmark(title);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
constructor(title, fn){
|
|
145
|
-
if (fn) {
|
|
146
|
-
this.feed(title, fn);
|
|
147
|
-
} else {
|
|
148
|
-
this.feed(title);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
feed(title, fn) {
|
|
152
|
-
const self = this;
|
|
153
|
-
self.#feeds.push(fn ? new FeedContext(title, fn) : new FeedContext(title));
|
|
154
|
-
return self;
|
|
155
|
-
}
|
|
156
|
-
target(title, setup) {
|
|
157
|
-
const target = new TargetContext(title, setup);
|
|
158
|
-
this.#targets.push(target);
|
|
159
|
-
return new Target(target);
|
|
160
|
-
}
|
|
161
|
-
async execute(options) {
|
|
162
|
-
const { workers = DEFAULT_WORKERS, warmupCycles = 20, maxCycles = _typescjs.DEFAULT_CYCLES, minCycles = 50, absThreshold = 1_000, relThreshold = 0.02, gcObserver = true, reportTypes = DEFAULT_REPORT_TYPES, progress = false, progressInterval = 100 } = options;
|
|
163
|
-
if (this.#executed) {
|
|
164
|
-
throw new Error("Benchmark is executed and can't be reused");
|
|
165
|
-
}
|
|
166
|
-
this.#executed = true;
|
|
167
|
-
const benchmarkUrl = options[BENCHMARK_URL];
|
|
168
|
-
const totalBenchmarks = this.#targets.reduce((acc, t)=>acc + t.measures.length * this.#feeds.length, 0);
|
|
169
|
-
const progressMap = new Map();
|
|
170
|
-
let completedBenchmarks = 0;
|
|
171
|
-
let bar = null;
|
|
172
|
-
if (progress && totalBenchmarks > 0) {
|
|
173
|
-
bar = new _progress.default(' [:bar] :percent :current/:total :label', {
|
|
174
|
-
total: totalBenchmarks * 100,
|
|
175
|
-
width: 30,
|
|
176
|
-
complete: '=',
|
|
177
|
-
incomplete: ' '
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
const onProgress = progress ? (info)=>{
|
|
181
|
-
progressMap.set(info.id, info.progress);
|
|
182
|
-
const totalProgress = (completedBenchmarks + [
|
|
183
|
-
...progressMap.values()
|
|
184
|
-
].reduce((a, b)=>a + b, 0)) * 100;
|
|
185
|
-
const label = info.id.length > 30 ? info.id.slice(0, 27) + '...' : info.id;
|
|
186
|
-
bar?.update(totalProgress / (totalBenchmarks * 100), {
|
|
187
|
-
label
|
|
188
|
-
});
|
|
189
|
-
} : undefined;
|
|
190
|
-
const executor = (0, _executorcjs.createExecutor)({
|
|
191
|
-
workers,
|
|
192
|
-
warmupCycles,
|
|
193
|
-
maxCycles,
|
|
194
|
-
minCycles,
|
|
195
|
-
absThreshold,
|
|
196
|
-
relThreshold,
|
|
197
|
-
gcObserver,
|
|
198
|
-
reportTypes,
|
|
199
|
-
onProgress,
|
|
200
|
-
progressInterval,
|
|
201
|
-
[BENCHMARK_URL]: benchmarkUrl
|
|
202
|
-
});
|
|
203
|
-
const reports = [];
|
|
204
|
-
for (const target of this.#targets){
|
|
205
|
-
const targetReport = {
|
|
206
|
-
target: target.title,
|
|
207
|
-
measures: []
|
|
208
|
-
};
|
|
209
|
-
for (const measure of target.measures){
|
|
210
|
-
const measureReport = {
|
|
211
|
-
measure: measure.title,
|
|
212
|
-
feeds: []
|
|
213
|
-
};
|
|
214
|
-
for (const feed of this.#feeds){
|
|
215
|
-
const id = `${target.title}/${measure.title}/${feed.title}`;
|
|
216
|
-
const data = await feed.fn?.();
|
|
217
|
-
executor.push({
|
|
218
|
-
id,
|
|
219
|
-
setup: target.setup,
|
|
220
|
-
teardown: target.teardown,
|
|
221
|
-
pre: measure.pre,
|
|
222
|
-
run: measure.run,
|
|
223
|
-
post: measure.post,
|
|
224
|
-
data
|
|
225
|
-
}).then((data)=>{
|
|
226
|
-
progressMap.delete(id);
|
|
227
|
-
completedBenchmarks++;
|
|
228
|
-
measureReport.feeds.push({
|
|
229
|
-
feed: feed.title,
|
|
230
|
-
data
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
targetReport.measures.push(measureReport);
|
|
235
|
-
}
|
|
236
|
-
reports.push(targetReport);
|
|
237
|
-
}
|
|
238
|
-
await executor.drain();
|
|
239
|
-
executor.kill();
|
|
240
|
-
if (bar) {
|
|
241
|
-
bar.update(1, {
|
|
242
|
-
label: 'done'
|
|
243
|
-
});
|
|
244
|
-
bar.terminate();
|
|
245
|
-
}
|
|
246
|
-
return reports;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
const printSimpleReports = (reports)=>{
|
|
250
|
-
for (const report of reports){
|
|
251
|
-
for (const { measure, feeds } of report.measures){
|
|
252
|
-
console.group('\n', report.target, measure);
|
|
253
|
-
for (const { feed, data } of feeds){
|
|
254
|
-
const { count, heapUsedKB, dceWarning, error: benchError, ...metrics } = data;
|
|
255
|
-
if (benchError) {
|
|
256
|
-
console.log(feed, `\x1b[31m[error: ${benchError}]\x1b[0m`);
|
|
257
|
-
continue;
|
|
258
|
-
}
|
|
259
|
-
const output = Object.entries(metrics).map(([key, report])=>`${key}: ${report.toString()}`).join('; ');
|
|
260
|
-
const extras = [];
|
|
261
|
-
if (heapUsedKB) extras.push(`heap: ${heapUsedKB}KB`);
|
|
262
|
-
if (dceWarning) extras.push('\x1b[33m[DCE warning]\x1b[0m');
|
|
263
|
-
const extrasStr = extras.length > 0 ? ` (${extras.join(', ')})` : '';
|
|
264
|
-
console.log(feed, output + extrasStr);
|
|
265
|
-
}
|
|
266
|
-
console.groupEnd();
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
const printTableReports = (reports)=>{
|
|
271
|
-
for (const report of reports){
|
|
272
|
-
for (const { measure, feeds } of report.measures){
|
|
273
|
-
console.log('\n', report.target, measure);
|
|
274
|
-
const table = {};
|
|
275
|
-
for (const { feed, data } of feeds){
|
|
276
|
-
const { error: benchError } = data;
|
|
277
|
-
if (benchError) {
|
|
278
|
-
table[feed] = {
|
|
279
|
-
error: benchError
|
|
280
|
-
};
|
|
281
|
-
} else {
|
|
282
|
-
table[feed] = Object.fromEntries(Object.entries(data).map(([key, report])=>[
|
|
283
|
-
key,
|
|
284
|
-
report.toString()
|
|
285
|
-
]));
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
console.table(table);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
const printJSONReports = (reports, padding)=>{
|
|
293
|
-
const output = {};
|
|
294
|
-
for (const report of reports){
|
|
295
|
-
for (const { measure, feeds } of report.measures){
|
|
296
|
-
const row = {};
|
|
297
|
-
for (const { feed, data } of feeds){
|
|
298
|
-
const { error: benchError } = data;
|
|
299
|
-
if (benchError) {
|
|
300
|
-
row[feed] = {
|
|
301
|
-
error: String(benchError)
|
|
302
|
-
};
|
|
303
|
-
} else {
|
|
304
|
-
row[feed] = Object.fromEntries(Object.entries(data).map(([key, report])=>[
|
|
305
|
-
key,
|
|
306
|
-
report.toString()
|
|
307
|
-
]));
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
output[`${report.target} ${measure}`] = row;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
console.log(JSON.stringify(output, null, padding));
|
|
314
|
-
};
|
|
315
|
-
const printMarkdownReports = (reports)=>{
|
|
316
|
-
for (const report of reports){
|
|
317
|
-
for (const { measure, feeds } of report.measures){
|
|
318
|
-
console.log(`\n## ${report.target} - ${measure}\n`);
|
|
319
|
-
if (feeds.length === 0) continue;
|
|
320
|
-
const firstValid = feeds.find((f)=>!f.data.error);
|
|
321
|
-
if (!firstValid) {
|
|
322
|
-
for (const { feed, data } of feeds){
|
|
323
|
-
console.log(`| ${feed} | error: ${data.error} |`);
|
|
324
|
-
}
|
|
325
|
-
continue;
|
|
326
|
-
}
|
|
327
|
-
const keys = Object.keys(firstValid.data).filter((k)=>k !== 'count' && k !== 'error');
|
|
328
|
-
const header = [
|
|
329
|
-
'Feed',
|
|
330
|
-
...keys
|
|
331
|
-
].join(' | ');
|
|
332
|
-
const separator = [
|
|
333
|
-
'---',
|
|
334
|
-
...keys.map(()=>'---')
|
|
335
|
-
].join(' | ');
|
|
336
|
-
console.log(`| ${header} |`);
|
|
337
|
-
console.log(`| ${separator} |`);
|
|
338
|
-
for (const { feed, data } of feeds){
|
|
339
|
-
if (data.error) {
|
|
340
|
-
console.log(`| ${feed} | error: ${data.error} |`);
|
|
341
|
-
continue;
|
|
342
|
-
}
|
|
343
|
-
const values = keys.map((k)=>data[k]?.toString() ?? '-');
|
|
344
|
-
console.log(`| ${[
|
|
345
|
-
feed,
|
|
346
|
-
...values
|
|
347
|
-
].join(' | ')} |`);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
const printHistogramReports = (reports, width = 40)=>{
|
|
353
|
-
for (const report of reports){
|
|
354
|
-
for (const { measure, feeds } of report.measures){
|
|
355
|
-
console.log(`\n${report.target} - ${measure}\n`);
|
|
356
|
-
const opsKey = 'ops';
|
|
357
|
-
const values = feeds.map((f)=>{
|
|
358
|
-
const { error: benchError } = f.data;
|
|
359
|
-
return {
|
|
360
|
-
feed: f.feed,
|
|
361
|
-
value: benchError ? 0 : f.data[opsKey]?.valueOf() ?? 0,
|
|
362
|
-
error: benchError
|
|
363
|
-
};
|
|
364
|
-
});
|
|
365
|
-
const maxValue = Math.max(...values.map((v)=>v.value));
|
|
366
|
-
const maxLabelLen = Math.max(...values.map((v)=>v.feed.length));
|
|
367
|
-
for (const { feed, value, error } of values){
|
|
368
|
-
const label = feed.padEnd(maxLabelLen);
|
|
369
|
-
if (error) {
|
|
370
|
-
console.log(` ${label} | \x1b[31m[error: ${error}]\x1b[0m`);
|
|
371
|
-
continue;
|
|
372
|
-
}
|
|
373
|
-
const barLen = maxValue > 0 ? Math.round(value / maxValue * width) : 0;
|
|
374
|
-
const bar = '\u2588'.repeat(barLen);
|
|
375
|
-
const formatted = value.toLocaleString('en-US', {
|
|
376
|
-
maximumFractionDigits: 2
|
|
377
|
-
});
|
|
378
|
-
console.log(` ${label} | ${bar} ${formatted} ops/s`);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
const reportsToBaseline = (reports)=>{
|
|
384
|
-
const results = {};
|
|
385
|
-
for (const report of reports){
|
|
386
|
-
for (const { measure, feeds } of report.measures){
|
|
387
|
-
for (const { feed, data } of feeds){
|
|
388
|
-
if (data.error) continue;
|
|
389
|
-
const key = `${report.target}/${measure}/${feed}`;
|
|
390
|
-
results[key] = {};
|
|
391
|
-
for (const [metric, value] of Object.entries(data)){
|
|
392
|
-
if (metric !== 'count' && typeof value.valueOf === 'function') {
|
|
393
|
-
results[key][metric] = value.valueOf();
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
return {
|
|
400
|
-
version: 1,
|
|
401
|
-
timestamp: new Date().toISOString(),
|
|
402
|
-
results
|
|
403
|
-
};
|
|
404
|
-
};
|
|
405
|
-
const printComparisonReports = (reports, baseline, threshold = 5)=>{
|
|
406
|
-
for (const report of reports){
|
|
407
|
-
for (const { measure, feeds } of report.measures){
|
|
408
|
-
console.log(`\n${report.target} - ${measure}\n`);
|
|
409
|
-
for (const { feed, data } of feeds){
|
|
410
|
-
const key = `${report.target}/${measure}/${feed}`;
|
|
411
|
-
const baselineData = baseline.results[key];
|
|
412
|
-
console.log(` ${feed}:`);
|
|
413
|
-
if (data.error) {
|
|
414
|
-
console.log(` \x1b[31m[error: ${data.error}]\x1b[0m`);
|
|
415
|
-
continue;
|
|
416
|
-
}
|
|
417
|
-
for (const [metric, value] of Object.entries(data)){
|
|
418
|
-
if (metric === 'count') continue;
|
|
419
|
-
const current = value.valueOf();
|
|
420
|
-
const baselineValue = baselineData?.[metric];
|
|
421
|
-
if (baselineValue !== undefined && baselineValue !== 0) {
|
|
422
|
-
const change = (current - baselineValue) / baselineValue * 100;
|
|
423
|
-
const isOps = metric === 'ops';
|
|
424
|
-
const improved = isOps ? change > threshold : change < -threshold;
|
|
425
|
-
const regressed = isOps ? change < -threshold : change > threshold;
|
|
426
|
-
let indicator = ' ';
|
|
427
|
-
if (improved) indicator = '\x1b[32m+\x1b[0m';
|
|
428
|
-
else if (regressed) indicator = '\x1b[31m!\x1b[0m';
|
|
429
|
-
const changeStr = change >= 0 ? `+${change.toFixed(1)}%` : `${change.toFixed(1)}%`;
|
|
430
|
-
const coloredChange = regressed ? `\x1b[31m${changeStr}\x1b[0m` : improved ? `\x1b[32m${changeStr}\x1b[0m` : changeStr;
|
|
431
|
-
console.log(` ${indicator} ${metric}: ${value.toString()} (${coloredChange})`);
|
|
432
|
-
} else {
|
|
433
|
-
console.log(` * ${metric}: ${value.toString()} (new)`);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
console.log(`\nBaseline from: ${baseline.timestamp}`);
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
//# sourceMappingURL=index.cjs.map
|
package/build/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { cpus } from 'node:os';\nimport Progress from 'progress';\nimport { createExecutor, ExecutorOptions, ExecutorReport } from './executor.js';\nimport { MaybePromise, StepFn, SetupFn, TeardownFn, FeedFn, ReportType, ReportTypeList, DEFAULT_CYCLES, ProgressInfo } from './types.js';\n\ndeclare global {\n const benchmark: typeof Benchmark.create;\n}\n\nexport const DEFAULT_WORKERS = Math.max(1, Math.ceil(cpus().length / 4));\n\nexport const AsyncFunction = (async () => {}).constructor;\nconst BENCHMARK_URL = Symbol.for('overtake.benchmarkUrl');\n\nexport interface TargetReport<R extends ReportTypeList> {\n target: string;\n measures: MeasureReport<R>[];\n}\n\nexport interface MeasureReport<R extends ReportTypeList> {\n measure: string;\n feeds: FeedReport<R>[];\n}\n\nexport interface FeedReport<R extends ReportTypeList> {\n feed: string;\n data: ExecutorReport<R>;\n}\n\nexport const DEFAULT_REPORT_TYPES = ['ops'] as const;\nexport type DefaultReportTypes = (typeof DEFAULT_REPORT_TYPES)[number];\n\nexport class MeasureContext<TContext, TInput> {\n public pre?: StepFn<TContext, TInput>;\n public post?: StepFn<TContext, TInput>;\n\n constructor(\n public title: string,\n public run: StepFn<TContext, TInput>,\n ) {}\n}\n\nexport class Measure<TContext, TInput> {\n #ctx: MeasureContext<TContext, TInput>;\n\n constructor(ctx: MeasureContext<TContext, TInput>) {\n this.#ctx = ctx;\n }\n\n pre(fn: StepFn<TContext, TInput>): Measure<TContext, TInput> {\n this.#ctx.pre = fn;\n return this;\n }\n post(fn: StepFn<TContext, TInput>): Measure<TContext, TInput> {\n this.#ctx.post = fn;\n return this;\n }\n}\n\nexport class TargetContext<TContext, TInput> {\n public teardown?: TeardownFn<TContext>;\n public measures: MeasureContext<TContext, TInput>[] = [];\n\n constructor(\n readonly title: string,\n readonly setup?: SetupFn<MaybePromise<TContext>>,\n ) {}\n}\n\nexport class Target<TContext, TInput> {\n #ctx: TargetContext<TContext, TInput>;\n\n constructor(ctx: TargetContext<TContext, TInput>) {\n this.#ctx = ctx;\n }\n teardown(fn: TeardownFn<TContext>): Target<TContext, TInput> {\n this.#ctx.teardown = fn;\n\n return this;\n }\n measure(title: string, run: StepFn<TContext, TInput>): Measure<TContext, TInput> {\n const measure = new MeasureContext(title, run);\n this.#ctx.measures.push(measure);\n\n return new Measure(measure);\n }\n}\n\nexport class FeedContext<TInput> {\n constructor(\n readonly title: string,\n readonly fn?: FeedFn<TInput>,\n ) {}\n}\n\nexport class Benchmark<TInput> {\n #targets: TargetContext<unknown, TInput>[] = [];\n #feeds: FeedContext<TInput>[] = [];\n #executed = false;\n\n static create(title: string): Benchmark<void>;\n static create<I>(title: string, fn: FeedFn<I>): Benchmark<I>;\n static create<I>(title: string, fn?: FeedFn<I> | undefined): Benchmark<I> {\n if (fn) {\n return new Benchmark(title, fn);\n } else {\n return new Benchmark(title);\n }\n }\n\n constructor(title: string);\n constructor(title: string, fn: FeedFn<TInput>);\n constructor(title: string, fn?: FeedFn<TInput> | undefined) {\n if (fn) {\n this.feed(title, fn);\n } else {\n this.feed(title);\n }\n }\n\n feed(title: string): Benchmark<TInput | void>;\n feed<I>(title: string, fn: FeedFn<I>): Benchmark<TInput | I>;\n feed<I>(title: string, fn?: FeedFn<I> | undefined): Benchmark<TInput | I> {\n const self = this as Benchmark<TInput | I>;\n self.#feeds.push(fn ? new FeedContext(title, fn) : new FeedContext(title));\n\n return self;\n }\n\n target<TContext>(title: string): Target<void, TInput>;\n target<TContext>(title: string, setup: SetupFn<Awaited<TContext>>): Target<TContext, TInput>;\n target<TContext>(title: string, setup?: SetupFn<Awaited<TContext>> | undefined): Target<TContext, TInput> {\n const target = new TargetContext<TContext, TInput>(title, setup);\n this.#targets.push(target as TargetContext<unknown, TInput>);\n\n return new Target<TContext, TInput>(target);\n }\n\n async execute<R extends readonly ReportType[] = typeof DEFAULT_REPORT_TYPES>(options: ExecutorOptions<R> & { progress?: boolean }): Promise<TargetReport<R>[]> {\n const {\n workers = DEFAULT_WORKERS,\n warmupCycles = 20,\n maxCycles = DEFAULT_CYCLES,\n minCycles = 50,\n absThreshold = 1_000,\n relThreshold = 0.02,\n gcObserver = true,\n reportTypes = DEFAULT_REPORT_TYPES as unknown as R,\n progress = false,\n progressInterval = 100,\n } = options;\n if (this.#executed) {\n throw new Error(\"Benchmark is executed and can't be reused\");\n }\n this.#executed = true;\n const benchmarkUrl = (options as unknown as Record<symbol, unknown>)[BENCHMARK_URL];\n\n const totalBenchmarks = this.#targets.reduce((acc, t) => acc + t.measures.length * this.#feeds.length, 0);\n const progressMap = new Map<string, number>();\n let completedBenchmarks = 0;\n let bar: Progress | null = null;\n\n if (progress && totalBenchmarks > 0) {\n bar = new Progress(' [:bar] :percent :current/:total :label', {\n total: totalBenchmarks * 100,\n width: 30,\n complete: '=',\n incomplete: ' ',\n });\n }\n\n const onProgress = progress\n ? (info: ProgressInfo) => {\n progressMap.set(info.id, info.progress);\n const totalProgress = (completedBenchmarks + [...progressMap.values()].reduce((a, b) => a + b, 0)) * 100;\n const label = info.id.length > 30 ? info.id.slice(0, 27) + '...' : info.id;\n bar?.update(totalProgress / (totalBenchmarks * 100), { label });\n }\n : undefined;\n\n const executor = createExecutor<unknown, TInput, R>({\n workers,\n warmupCycles,\n maxCycles,\n minCycles,\n absThreshold,\n relThreshold,\n gcObserver,\n reportTypes,\n onProgress,\n progressInterval,\n [BENCHMARK_URL]: benchmarkUrl,\n } as Required<ExecutorOptions<R>>);\n\n const reports: TargetReport<R>[] = [];\n for (const target of this.#targets) {\n const targetReport: TargetReport<R> = { target: target.title, measures: [] };\n for (const measure of target.measures) {\n const measureReport: MeasureReport<R> = { measure: measure.title, feeds: [] };\n for (const feed of this.#feeds) {\n const id = `${target.title}/${measure.title}/${feed.title}`;\n const data = await feed.fn?.();\n executor\n .push<ExecutorReport<R>>({\n id,\n setup: target.setup,\n teardown: target.teardown,\n pre: measure.pre,\n run: measure.run,\n post: measure.post,\n data,\n })\n .then((data) => {\n progressMap.delete(id);\n completedBenchmarks++;\n measureReport.feeds.push({\n feed: feed.title,\n data,\n });\n });\n }\n targetReport.measures.push(measureReport);\n }\n reports.push(targetReport);\n }\n await executor.drain();\n executor.kill();\n\n if (bar) {\n bar.update(1, { label: 'done' });\n bar.terminate();\n }\n\n return reports;\n }\n}\n\nexport const printSimpleReports = <R extends ReportTypeList>(reports: TargetReport<R>[]) => {\n for (const report of reports) {\n for (const { measure, feeds } of report.measures) {\n console.group('\\n', report.target, measure);\n for (const { feed, data } of feeds) {\n const { count, heapUsedKB, dceWarning, error: benchError, ...metrics } = data as Record<string, unknown>;\n if (benchError) {\n console.log(feed, `\\x1b[31m[error: ${benchError}]\\x1b[0m`);\n continue;\n }\n const output = Object.entries(metrics)\n .map(([key, report]) => `${key}: ${(report as { toString(): string }).toString()}`)\n .join('; ');\n const extras: string[] = [];\n if (heapUsedKB) extras.push(`heap: ${heapUsedKB}KB`);\n if (dceWarning) extras.push('\\x1b[33m[DCE warning]\\x1b[0m');\n const extrasStr = extras.length > 0 ? ` (${extras.join(', ')})` : '';\n console.log(feed, output + extrasStr);\n }\n console.groupEnd();\n }\n }\n};\n\nexport const printTableReports = <R extends ReportTypeList>(reports: TargetReport<R>[]) => {\n for (const report of reports) {\n for (const { measure, feeds } of report.measures) {\n console.log('\\n', report.target, measure);\n const table: Record<string, unknown> = {};\n for (const { feed, data } of feeds) {\n const { error: benchError } = data as Record<string, unknown>;\n if (benchError) {\n table[feed] = { error: benchError };\n } else {\n table[feed] = Object.fromEntries(Object.entries(data).map(([key, report]) => [key, report.toString()]));\n }\n }\n console.table(table);\n }\n }\n};\n\nexport const printJSONReports = <R extends ReportTypeList>(reports: TargetReport<R>[], padding?: number) => {\n const output = {} as Record<string, Record<string, Record<string, string>>>;\n for (const report of reports) {\n for (const { measure, feeds } of report.measures) {\n const row = {} as Record<string, Record<string, string>>;\n for (const { feed, data } of feeds) {\n const { error: benchError } = data as Record<string, unknown>;\n if (benchError) {\n row[feed] = { error: String(benchError) };\n } else {\n row[feed] = Object.fromEntries(Object.entries(data).map(([key, report]) => [key, report.toString()]));\n }\n }\n output[`${report.target} ${measure}`] = row;\n }\n }\n console.log(JSON.stringify(output, null, padding));\n};\n\nexport const printMarkdownReports = <R extends ReportTypeList>(reports: TargetReport<R>[]) => {\n for (const report of reports) {\n for (const { measure, feeds } of report.measures) {\n console.log(`\\n## ${report.target} - ${measure}\\n`);\n if (feeds.length === 0) continue;\n\n const firstValid = feeds.find((f) => !(f.data as Record<string, unknown>).error);\n if (!firstValid) {\n for (const { feed, data } of feeds) {\n console.log(`| ${feed} | error: ${(data as Record<string, unknown>).error} |`);\n }\n continue;\n }\n const keys = Object.keys(firstValid.data).filter((k) => k !== 'count' && k !== 'error');\n const header = ['Feed', ...keys].join(' | ');\n const separator = ['---', ...keys.map(() => '---')].join(' | ');\n\n console.log(`| ${header} |`);\n console.log(`| ${separator} |`);\n\n for (const { feed, data } of feeds) {\n if ((data as Record<string, unknown>).error) {\n console.log(`| ${feed} | error: ${(data as Record<string, unknown>).error} |`);\n continue;\n }\n const values = keys.map((k) => (data as Record<string, { toString(): string }>)[k]?.toString() ?? '-');\n console.log(`| ${[feed, ...values].join(' | ')} |`);\n }\n }\n }\n};\n\nexport const printHistogramReports = <R extends ReportTypeList>(reports: TargetReport<R>[], width = 40) => {\n for (const report of reports) {\n for (const { measure, feeds } of report.measures) {\n console.log(`\\n${report.target} - ${measure}\\n`);\n\n const opsKey = 'ops';\n const values = feeds.map((f) => {\n const { error: benchError } = f.data as Record<string, unknown>;\n return {\n feed: f.feed,\n value: benchError ? 0 : ((f.data as Record<string, { valueOf(): number }>)[opsKey]?.valueOf() ?? 0),\n error: benchError as string | undefined,\n };\n });\n\n const maxValue = Math.max(...values.map((v) => v.value));\n const maxLabelLen = Math.max(...values.map((v) => v.feed.length));\n\n for (const { feed, value, error } of values) {\n const label = feed.padEnd(maxLabelLen);\n if (error) {\n console.log(` ${label} | \\x1b[31m[error: ${error}]\\x1b[0m`);\n continue;\n }\n const barLen = maxValue > 0 ? Math.round((value / maxValue) * width) : 0;\n const bar = '\\u2588'.repeat(barLen);\n const formatted = value.toLocaleString('en-US', { maximumFractionDigits: 2 });\n console.log(` ${label} | ${bar} ${formatted} ops/s`);\n }\n }\n }\n};\n\nexport interface BaselineData {\n version: number;\n timestamp: string;\n results: Record<string, Record<string, number>>;\n}\n\nexport const reportsToBaseline = <R extends ReportTypeList>(reports: TargetReport<R>[]): BaselineData => {\n const results: Record<string, Record<string, number>> = {};\n for (const report of reports) {\n for (const { measure, feeds } of report.measures) {\n for (const { feed, data } of feeds) {\n if ((data as Record<string, unknown>).error) continue;\n const key = `${report.target}/${measure}/${feed}`;\n results[key] = {};\n for (const [metric, value] of Object.entries(data)) {\n if (metric !== 'count' && typeof (value as { valueOf(): number }).valueOf === 'function') {\n results[key][metric] = (value as { valueOf(): number }).valueOf();\n }\n }\n }\n }\n }\n return {\n version: 1,\n timestamp: new Date().toISOString(),\n results,\n };\n};\n\nexport const printComparisonReports = <R extends ReportTypeList>(reports: TargetReport<R>[], baseline: BaselineData, threshold = 5) => {\n for (const report of reports) {\n for (const { measure, feeds } of report.measures) {\n console.log(`\\n${report.target} - ${measure}\\n`);\n\n for (const { feed, data } of feeds) {\n const key = `${report.target}/${measure}/${feed}`;\n const baselineData = baseline.results[key];\n\n console.log(` ${feed}:`);\n\n if ((data as Record<string, unknown>).error) {\n console.log(` \\x1b[31m[error: ${(data as Record<string, unknown>).error}]\\x1b[0m`);\n continue;\n }\n\n for (const [metric, value] of Object.entries(data)) {\n if (metric === 'count') continue;\n const current = (value as { valueOf(): number }).valueOf();\n const baselineValue = baselineData?.[metric];\n\n if (baselineValue !== undefined && baselineValue !== 0) {\n const change = ((current - baselineValue) / baselineValue) * 100;\n const isOps = metric === 'ops';\n const improved = isOps ? change > threshold : change < -threshold;\n const regressed = isOps ? change < -threshold : change > threshold;\n\n let indicator = ' ';\n if (improved) indicator = '\\x1b[32m+\\x1b[0m';\n else if (regressed) indicator = '\\x1b[31m!\\x1b[0m';\n\n const changeStr = change >= 0 ? `+${change.toFixed(1)}%` : `${change.toFixed(1)}%`;\n const coloredChange = regressed ? `\\x1b[31m${changeStr}\\x1b[0m` : improved ? `\\x1b[32m${changeStr}\\x1b[0m` : changeStr;\n\n console.log(` ${indicator} ${metric}: ${(value as { toString(): string }).toString()} (${coloredChange})`);\n } else {\n console.log(` * ${metric}: ${(value as { toString(): string }).toString()} (new)`);\n }\n }\n }\n }\n }\n\n console.log(`\\nBaseline from: ${baseline.timestamp}`);\n};\n"],"names":["AsyncFunction","Benchmark","DEFAULT_REPORT_TYPES","DEFAULT_WORKERS","FeedContext","Measure","MeasureContext","Target","TargetContext","printComparisonReports","printHistogramReports","printJSONReports","printMarkdownReports","printSimpleReports","printTableReports","reportsToBaseline","Math","max","ceil","cpus","length","BENCHMARK_URL","Symbol","for","pre","post","title","run","ctx","fn","teardown","measures","setup","measure","push","create","feed","self","target","execute","options","workers","warmupCycles","maxCycles","DEFAULT_CYCLES","minCycles","absThreshold","relThreshold","gcObserver","reportTypes","progress","progressInterval","Error","benchmarkUrl","totalBenchmarks","reduce","acc","t","progressMap","Map","completedBenchmarks","bar","Progress","total","width","complete","incomplete","onProgress","info","set","id","totalProgress","values","a","b","label","slice","update","undefined","executor","createExecutor","reports","targetReport","measureReport","feeds","data","then","delete","drain","kill","terminate","report","console","group","count","heapUsedKB","dceWarning","error","benchError","metrics","log","output","Object","entries","map","key","toString","join","extras","extrasStr","groupEnd","table","fromEntries","padding","row","String","JSON","stringify","firstValid","find","f","keys","filter","k","header","separator","opsKey","value","valueOf","maxValue","v","maxLabelLen","padEnd","barLen","round","repeat","formatted","toLocaleString","maximumFractionDigits","results","metric","version","timestamp","Date","toISOString","baseline","threshold","baselineData","current","baselineValue","change","isOps","improved","regressed","indicator","changeStr","to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