@yaks/benchmark 0.0.0-stage → 0.2.36
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/LICENSE +202 -0
- package/README.md +457 -2
- package/_dist/bench.d.ts +27 -0
- package/_dist/bench.d.ts.map +1 -0
- package/_dist/deno.d.ts +21 -0
- package/_dist/deno.d.ts.map +1 -0
- package/_dist/host.d.ts +42 -0
- package/_dist/host.d.ts.map +1 -0
- package/_dist/mod.d.ts +8 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/process.d.ts +2 -0
- package/_dist/process.d.ts.map +1 -0
- package/_dist/ratchet.d.ts +64 -0
- package/_dist/ratchet.d.ts.map +1 -0
- package/_dist/result.d.ts +103 -0
- package/_dist/result.d.ts.map +1 -0
- package/_dist/runner.d.ts +45 -0
- package/_dist/runner.d.ts.map +1 -0
- package/bench.js +89 -0
- package/bench.js.map +1 -0
- package/bench.ts +103 -0
- package/deno.js +35 -0
- package/deno.js.map +1 -0
- package/deno.json +1 -0
- package/deno.ts +50 -0
- package/host.js +145 -0
- package/host.js.map +1 -0
- package/host.ts +177 -0
- package/invocations.ts +127 -0
- package/mod.js +8 -0
- package/mod.js.map +1 -0
- package/mod.ts +51 -0
- package/package.json +22 -4
- package/process.js +53 -0
- package/process.js.map +1 -0
- package/process.ts +49 -0
- package/ratchet.js +290 -0
- package/ratchet.js.map +1 -0
- package/ratchet.ts +341 -0
- package/result.js +75 -0
- package/result.js.map +1 -0
- package/result.ts +221 -0
- package/runner.js +303 -0
- package/runner.js.map +1 -0
- package/runner.ts +406 -0
- package/rusage.js +25 -0
- package/rusage.js.map +1 -0
- package/rusage.ts +27 -0
package/result.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** The data shared by bench authors, the runner, the ratchet and reporters.
|
|
2
|
+
* Samples keep their round and provenance; a Deno average is never described
|
|
3
|
+
* as an individual operation's timing. No effect belongs in this module. */ /** Insufficient sampling is an observation, never a pass or a regression. */ export let insufficient = (run)=>run.verdict == 'inconclusive' || run.benches.some((bench)=>bench.samples?.some((sample)=>sample.sampling?.status == 'insufficient'));
|
|
4
|
+
export let value = (n)=>{
|
|
5
|
+
if (typeof n != 'number' || !Number.isFinite(n) || n < 0) {
|
|
6
|
+
throw new Error(`Expected a finite, nonnegative sample: ${n}`);
|
|
7
|
+
}
|
|
8
|
+
return n;
|
|
9
|
+
};
|
|
10
|
+
export let workload = (input)=>{
|
|
11
|
+
if (typeof input == 'number' ? !Number.isFinite(input) : typeof input != 'string' || !input) {
|
|
12
|
+
throw new Error('Expected a finite workload version or a nonempty string');
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export let median = (values)=>{
|
|
16
|
+
if (!values.length) throw new Error('Expected at least one sample');
|
|
17
|
+
let sorted = values.map(value).sort((a, b)=>a - b);
|
|
18
|
+
let middle = Math.floor(sorted.length / 2);
|
|
19
|
+
return sorted.length % 2 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
|
|
20
|
+
};
|
|
21
|
+
export let samples = (input)=>{
|
|
22
|
+
let out = typeof input == 'number' ? [
|
|
23
|
+
{
|
|
24
|
+
value: input
|
|
25
|
+
}
|
|
26
|
+
] : Array.isArray(input) ? input : [
|
|
27
|
+
input
|
|
28
|
+
];
|
|
29
|
+
if (!out.length) throw new Error('Expected at least one sample');
|
|
30
|
+
return out.map((s)=>{
|
|
31
|
+
value(s.value);
|
|
32
|
+
if (s.cpu !== undefined) value(s.cpu);
|
|
33
|
+
if (s.sampling) {
|
|
34
|
+
let { status, minimum, measured, outer } = s.sampling;
|
|
35
|
+
if (status != 'insufficient' || value(minimum) <= 0 || value(measured) >= minimum) throw new Error('Invalid CPU sampling observation');
|
|
36
|
+
value(outer);
|
|
37
|
+
}
|
|
38
|
+
for (let count of Object.values(s.counts ?? {}))value(count);
|
|
39
|
+
return {
|
|
40
|
+
...s,
|
|
41
|
+
counts: s.counts && {
|
|
42
|
+
...s.counts
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
export let names = (benches)=>{
|
|
48
|
+
let seen = new Set();
|
|
49
|
+
if (!benches.length) throw new Error('Expected at least one bench');
|
|
50
|
+
for (let b of benches){
|
|
51
|
+
if (typeof b.name != 'string' || !b.name || typeof b.unit != 'string' || !b.unit || seen.has(b.name)) {
|
|
52
|
+
throw new Error(`Missing name/unit or duplicate bench: ${b.name}`);
|
|
53
|
+
}
|
|
54
|
+
if (b.better != null && ![
|
|
55
|
+
'lower',
|
|
56
|
+
'higher'
|
|
57
|
+
].includes(b.better)) {
|
|
58
|
+
throw new Error(`Unknown direction: ${b.better}`);
|
|
59
|
+
}
|
|
60
|
+
if (b.resolution !== undefined && (!Number.isFinite(b.resolution) || b.resolution <= 0)) {
|
|
61
|
+
throw new Error(`Expected a finite, positive resolution: ${b.name}`);
|
|
62
|
+
}
|
|
63
|
+
seen.add(b.name);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
export let sameNames = (expected, actual)=>{
|
|
67
|
+
names(expected);
|
|
68
|
+
names(actual);
|
|
69
|
+
let a = actual.map((b)=>b.name).sort();
|
|
70
|
+
let e = expected.map((b)=>b.name).sort();
|
|
71
|
+
if (JSON.stringify(a) != JSON.stringify(e)) {
|
|
72
|
+
throw new Error(`Benchmark set changed: expected [${e}]; received [${a}]`);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=result.js.map
|
package/result.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sources":["./result.ts"],"names":[],"mappings":"AAAA;;0EAE0E,GAmI1E,2EAA2E,GAC3E,OAAO,IAAI,eAAe,CACxB,MAEA,IAAI,OAAO,IAAI,kBACf,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,QAChB,MAAM,OAAO,EAAE,KAAK,CAAC,SAAW,OAAO,QAAQ,EAAE,UAAU,iBAC5D;AAEH,OAAO,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E,aAAa,EAAE,EAAE,CAAC,CAAC;EAC3E;AACF,EAAC"}
|
package/result.ts
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/** The data shared by bench authors, the runner, the ratchet and reporters.
|
|
2
|
+
* Samples keep their round and provenance; a Deno average is never described
|
|
3
|
+
* as an individual operation's timing. No effect belongs in this module. */
|
|
4
|
+
|
|
5
|
+
import type { Event } from 'jsr:@yaks/trace@0.2.36'
|
|
6
|
+
|
|
7
|
+
/** The collector kept the CPU reading but could not sample enough timed work.
|
|
8
|
+
* Durations are total CPU milliseconds, before per-operation normalization. */
|
|
9
|
+
export type Sampling = {
|
|
10
|
+
status: 'insufficient'
|
|
11
|
+
minimum: number
|
|
12
|
+
measured: number
|
|
13
|
+
outer: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type Sample = {
|
|
17
|
+
value: number
|
|
18
|
+
/** The CPU time the step took, in the bench's unit: this process's and its
|
|
19
|
+
* finished children's (host.ts `cputime`). Absent where the step's work runs
|
|
20
|
+
* in a process that outlives it, or where the box does not say. */
|
|
21
|
+
cpu?: number
|
|
22
|
+
sampling?: Sampling
|
|
23
|
+
counts?: Record<string, number>
|
|
24
|
+
source?: string
|
|
25
|
+
details?: unknown
|
|
26
|
+
spans?: readonly Event[]
|
|
27
|
+
}
|
|
28
|
+
export type Samples = number | Sample | readonly Sample[]
|
|
29
|
+
export type Direction = 'lower' | 'higher'
|
|
30
|
+
export type Workload = {
|
|
31
|
+
name: string
|
|
32
|
+
unit: string
|
|
33
|
+
better?: Direction
|
|
34
|
+
/** Precision in this workload's unit, used to round the tolerance boundary. */
|
|
35
|
+
resolution?: number
|
|
36
|
+
}
|
|
37
|
+
export type Bench = Workload & {
|
|
38
|
+
sample: (round: number) => Samples | Promise<Samples>
|
|
39
|
+
}
|
|
40
|
+
export type Suite = {
|
|
41
|
+
name: string
|
|
42
|
+
/** The aggregation contract, compared verbatim by the ratchet. */
|
|
43
|
+
metric: string
|
|
44
|
+
/** Change this when the corpus or timed boundary changes. */
|
|
45
|
+
workload: string | number
|
|
46
|
+
benches: readonly Bench[]
|
|
47
|
+
/** Release collection resources after the final round, including failures. */
|
|
48
|
+
close?: () => void | Promise<void>
|
|
49
|
+
}
|
|
50
|
+
/** A shared collector can measure several workloads in one external process. */
|
|
51
|
+
export type CollectedSuite = Omit<Suite, 'benches'> & {
|
|
52
|
+
benches: readonly Workload[]
|
|
53
|
+
collect: (round: number) =>
|
|
54
|
+
| Record<string, Samples>
|
|
55
|
+
| Promise<Record<string, Samples>>
|
|
56
|
+
}
|
|
57
|
+
export type Round = {
|
|
58
|
+
index: number
|
|
59
|
+
median: number
|
|
60
|
+
/** The median of its samples' CPU time, where every sample has one. */
|
|
61
|
+
cpu?: number
|
|
62
|
+
/** Reserved for the recorded span tree, rather than live channel history. */
|
|
63
|
+
spans: readonly Event[] | null
|
|
64
|
+
}
|
|
65
|
+
export type Result = Workload & {
|
|
66
|
+
better: Direction
|
|
67
|
+
samples: (Sample & { round: number })[]
|
|
68
|
+
rounds: Round[]
|
|
69
|
+
median: number
|
|
70
|
+
/** How far apart its round medians fell, across every run of the
|
|
71
|
+
* measurement, as a fraction of the best (ratchet.ts `spread`): the noise
|
|
72
|
+
* this figure carries. */
|
|
73
|
+
spread: number
|
|
74
|
+
/** The median round's recorded span tree. */
|
|
75
|
+
spans: readonly Event[] | null
|
|
76
|
+
}
|
|
77
|
+
export type Regression = {
|
|
78
|
+
reference?: string
|
|
79
|
+
name: string
|
|
80
|
+
unit: string
|
|
81
|
+
baseline: number
|
|
82
|
+
/** The figure the bench was allowed to reach: its baseline and slack. */
|
|
83
|
+
limit: number
|
|
84
|
+
current: number
|
|
85
|
+
/** A positive fraction is worse, for either direction. */
|
|
86
|
+
change: number | null
|
|
87
|
+
}
|
|
88
|
+
export type Run = {
|
|
89
|
+
version: 1
|
|
90
|
+
suite: string
|
|
91
|
+
metric: string
|
|
92
|
+
workload: string | number
|
|
93
|
+
at: string
|
|
94
|
+
commit: string | null
|
|
95
|
+
runtime: string
|
|
96
|
+
cpu: string
|
|
97
|
+
/** The box's one, five and fifteen minute load averages as the run began. */
|
|
98
|
+
load: readonly number[]
|
|
99
|
+
/** The most of the box's CPUs other work used in the second before a
|
|
100
|
+
* round, while the bench rested (host.ts `busy`), or null where the box
|
|
101
|
+
* does not say. Over BUSY, the run is loaded (ratchet.ts `loaded`). */
|
|
102
|
+
busy: number | null
|
|
103
|
+
rounds: number
|
|
104
|
+
benches: Result[]
|
|
105
|
+
tolerance: number | null
|
|
106
|
+
/** `loaded`: a figure was past its limit on a loaded box.
|
|
107
|
+
* `inconclusive`: CPU sampling was insufficient; readings remain diagnostic. */
|
|
108
|
+
verdict:
|
|
109
|
+
| 'measured'
|
|
110
|
+
| 'passed'
|
|
111
|
+
| 'regressed'
|
|
112
|
+
| 'loaded'
|
|
113
|
+
| 'accepted'
|
|
114
|
+
| 'inconclusive'
|
|
115
|
+
regressions: Regression[]
|
|
116
|
+
}
|
|
117
|
+
export type Baseline =
|
|
118
|
+
& Pick<Run, 'version' | 'suite' | 'metric' | 'workload' | 'runtime' | 'cpu'>
|
|
119
|
+
& {
|
|
120
|
+
/** The revision measured when converting a baseline to a new metric. */
|
|
121
|
+
reference?: string
|
|
122
|
+
/** The slack a bench without its own may take. */
|
|
123
|
+
tolerance: number
|
|
124
|
+
benches: (Workload & {
|
|
125
|
+
better: Direction
|
|
126
|
+
/** The product revision this individual workload was banked against. */
|
|
127
|
+
reference?: string
|
|
128
|
+
median: number
|
|
129
|
+
/** The slack this bench measured for itself when it was banked. */
|
|
130
|
+
tolerance?: number
|
|
131
|
+
})[]
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Insufficient sampling is an observation, never a pass or a regression. */
|
|
135
|
+
export let insufficient = (
|
|
136
|
+
run: Pick<Run, 'benches'> & Partial<Pick<Run, 'verdict'>>,
|
|
137
|
+
): boolean =>
|
|
138
|
+
run.verdict == 'inconclusive' ||
|
|
139
|
+
run.benches.some((bench) =>
|
|
140
|
+
bench.samples?.some((sample) => sample.sampling?.status == 'insufficient')
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
export let value = (n: number): number => {
|
|
144
|
+
if (typeof n != 'number' || !Number.isFinite(n) || n < 0) {
|
|
145
|
+
throw new Error(`Expected a finite, nonnegative sample: ${n}`)
|
|
146
|
+
}
|
|
147
|
+
return n
|
|
148
|
+
}
|
|
149
|
+
export let workload = (input: string | number): void => {
|
|
150
|
+
if (
|
|
151
|
+
typeof input == 'number'
|
|
152
|
+
? !Number.isFinite(input)
|
|
153
|
+
: typeof input != 'string' || !input
|
|
154
|
+
) {
|
|
155
|
+
throw new Error('Expected a finite workload version or a nonempty string')
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
export let median = (values: readonly number[]): number => {
|
|
159
|
+
if (!values.length) throw new Error('Expected at least one sample')
|
|
160
|
+
let sorted = values.map(value).sort((a, b) => a - b)
|
|
161
|
+
let middle = Math.floor(sorted.length / 2)
|
|
162
|
+
return sorted.length % 2
|
|
163
|
+
? sorted[middle]
|
|
164
|
+
: (sorted[middle - 1] + sorted[middle]) / 2
|
|
165
|
+
}
|
|
166
|
+
export let samples = (input: Samples): Sample[] => {
|
|
167
|
+
let out: readonly Sample[] = typeof input == 'number'
|
|
168
|
+
? [{ value: input }]
|
|
169
|
+
: Array.isArray(input)
|
|
170
|
+
? input
|
|
171
|
+
: [input as Sample]
|
|
172
|
+
if (!out.length) throw new Error('Expected at least one sample')
|
|
173
|
+
return out.map((s) => {
|
|
174
|
+
value(s.value)
|
|
175
|
+
if (s.cpu !== undefined) value(s.cpu)
|
|
176
|
+
if (s.sampling) {
|
|
177
|
+
let { status, minimum, measured, outer } = s.sampling
|
|
178
|
+
if (
|
|
179
|
+
status != 'insufficient' || value(minimum) <= 0 ||
|
|
180
|
+
value(measured) >= minimum
|
|
181
|
+
) throw new Error('Invalid CPU sampling observation')
|
|
182
|
+
value(outer)
|
|
183
|
+
}
|
|
184
|
+
for (let count of Object.values(s.counts ?? {})) value(count)
|
|
185
|
+
return { ...s, counts: s.counts && { ...s.counts } }
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
export let names = (benches: readonly Workload[]): void => {
|
|
189
|
+
let seen = new Set<string>()
|
|
190
|
+
if (!benches.length) throw new Error('Expected at least one bench')
|
|
191
|
+
for (let b of benches) {
|
|
192
|
+
if (
|
|
193
|
+
typeof b.name != 'string' || !b.name || typeof b.unit != 'string' ||
|
|
194
|
+
!b.unit || seen.has(b.name)
|
|
195
|
+
) {
|
|
196
|
+
throw new Error(`Missing name/unit or duplicate bench: ${b.name}`)
|
|
197
|
+
}
|
|
198
|
+
if (b.better != null && !['lower', 'higher'].includes(b.better)) {
|
|
199
|
+
throw new Error(`Unknown direction: ${b.better}`)
|
|
200
|
+
}
|
|
201
|
+
if (
|
|
202
|
+
b.resolution !== undefined &&
|
|
203
|
+
(!Number.isFinite(b.resolution) || b.resolution <= 0)
|
|
204
|
+
) {
|
|
205
|
+
throw new Error(`Expected a finite, positive resolution: ${b.name}`)
|
|
206
|
+
}
|
|
207
|
+
seen.add(b.name)
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
export let sameNames = (
|
|
211
|
+
expected: readonly Workload[],
|
|
212
|
+
actual: readonly Workload[],
|
|
213
|
+
): void => {
|
|
214
|
+
names(expected)
|
|
215
|
+
names(actual)
|
|
216
|
+
let a = actual.map((b) => b.name).sort()
|
|
217
|
+
let e = expected.map((b) => b.name).sort()
|
|
218
|
+
if (JSON.stringify(a) != JSON.stringify(e)) {
|
|
219
|
+
throw new Error(`Benchmark set changed: expected [${e}]; received [${a}]`)
|
|
220
|
+
}
|
|
221
|
+
}
|
package/runner.js
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import * as io from "@yaks/file/io";
|
|
2
|
+
import * as system from "@yaks/process/system";
|
|
3
|
+
/** Run workloads sequentially, persist JSON before reporting, and accept one
|
|
4
|
+
* suite's baseline only on request. External collectors use the same ratchet
|
|
5
|
+
* and reporting path as timed callbacks. */ import { host, reporters } from "./host.js";
|
|
6
|
+
import { dirname, resolve } from 'node:path';
|
|
7
|
+
import { insufficient, median, names, sameNames, samples, workload } from "./result.js";
|
|
8
|
+
import { baseline, best, compare, covered, incomparable, loaded, rebased, spread, tolerance, validate } from "./ratchet.js";
|
|
9
|
+
/** An interrupted write never leaves a partial result or baseline. */ export let files = {
|
|
10
|
+
read: (path)=>io.readTextFile(path),
|
|
11
|
+
write: async (path, value)=>{
|
|
12
|
+
let tmp = `${path}.${crypto.randomUUID()}.tmp`;
|
|
13
|
+
try {
|
|
14
|
+
await io.mkdir(dirname(path), {
|
|
15
|
+
recursive: true
|
|
16
|
+
});
|
|
17
|
+
await io.writeTextFile(tmp, JSON.stringify(value, null, 2) + '\n');
|
|
18
|
+
await io.rename(tmp, path);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
try {
|
|
21
|
+
await io.remove(tmp);
|
|
22
|
+
} catch (cleanup) {
|
|
23
|
+
if (!io.isNotFound(cleanup)) {
|
|
24
|
+
console.error('Benchmark temporary file cleanup failed', cleanup);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export class Regressed extends Error {
|
|
32
|
+
result;
|
|
33
|
+
constructor(result){
|
|
34
|
+
super(`${result.regressions.length} benchmarks exceeded tolerance`), this.result = result;
|
|
35
|
+
this.name = 'Regressed';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export let run = async (suite, options)=>{
|
|
39
|
+
try {
|
|
40
|
+
if (!options.lock) return await execute(suite, options);
|
|
41
|
+
using lock = await (options.open ?? io.open)(options.lock, {
|
|
42
|
+
create: true,
|
|
43
|
+
read: true,
|
|
44
|
+
write: true
|
|
45
|
+
});
|
|
46
|
+
let exclusive = async (work)=>{
|
|
47
|
+
await lock.lock(true);
|
|
48
|
+
try {
|
|
49
|
+
await lock.truncate(0);
|
|
50
|
+
await lock.write(new TextEncoder().encode(`${system.pid}\n`));
|
|
51
|
+
return await work();
|
|
52
|
+
} finally{
|
|
53
|
+
await lock.unlock();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return await execute(suite, options, exclusive);
|
|
57
|
+
} finally{
|
|
58
|
+
await suite.close?.();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
let direct = (work)=>work();
|
|
62
|
+
let execute = async (suite, options, exclusive = direct)=>{
|
|
63
|
+
let rounds = options.rounds ?? 3;
|
|
64
|
+
let mode = options.mode ?? 'run';
|
|
65
|
+
if (!Number.isSafeInteger(rounds) || rounds < 1) {
|
|
66
|
+
throw new Error('Expected a positive integer round count');
|
|
67
|
+
}
|
|
68
|
+
if (![
|
|
69
|
+
'run',
|
|
70
|
+
'check',
|
|
71
|
+
'accept'
|
|
72
|
+
].includes(mode)) {
|
|
73
|
+
throw new Error(`Unknown mode: ${mode}`);
|
|
74
|
+
}
|
|
75
|
+
if (options.coverage && ![
|
|
76
|
+
'exact',
|
|
77
|
+
'subset'
|
|
78
|
+
].includes(options.coverage)) {
|
|
79
|
+
throw new Error(`Unknown benchmark coverage: ${options.coverage}`);
|
|
80
|
+
}
|
|
81
|
+
if (typeof suite.name != 'string' || !suite.name || typeof suite.metric != 'string' || !suite.metric || ![
|
|
82
|
+
'string',
|
|
83
|
+
'number'
|
|
84
|
+
].includes(typeof suite.workload)) throw new Error('Invalid suite metadata');
|
|
85
|
+
workload(suite.workload);
|
|
86
|
+
names(suite.benches);
|
|
87
|
+
if (!options.output || options.baseline && resolve(options.output) == resolve(options.baseline)) {
|
|
88
|
+
throw new Error('Result and baseline need separate paths');
|
|
89
|
+
}
|
|
90
|
+
if (options.baseline && !options.files) {
|
|
91
|
+
try {
|
|
92
|
+
let [output, base] = await Promise.all([
|
|
93
|
+
io.realPath(options.output),
|
|
94
|
+
io.realPath(options.baseline)
|
|
95
|
+
]);
|
|
96
|
+
if (output == base) {
|
|
97
|
+
throw new Error('Result and baseline need separate paths');
|
|
98
|
+
}
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (!io.isNotFound(error)) throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (mode != 'run' && !options.baseline) {
|
|
104
|
+
throw new Error('A check or acceptance needs a baseline path');
|
|
105
|
+
}
|
|
106
|
+
if (mode == 'accept') tolerance(options.tolerance);
|
|
107
|
+
if (mode == 'check' && options.tolerance != null) {
|
|
108
|
+
throw new Error('Checks use the baseline tolerance');
|
|
109
|
+
}
|
|
110
|
+
let repeats = options.runs ?? 1;
|
|
111
|
+
if (!Number.isSafeInteger(repeats) || repeats < 1) {
|
|
112
|
+
throw new Error('Expected a positive integer run count');
|
|
113
|
+
}
|
|
114
|
+
let store = options.files ?? files;
|
|
115
|
+
let readBase = async ()=>{
|
|
116
|
+
let base;
|
|
117
|
+
if (mode != 'run') {
|
|
118
|
+
try {
|
|
119
|
+
base = JSON.parse(await store.read(options.baseline));
|
|
120
|
+
} catch (error) {
|
|
121
|
+
if (mode == 'check' || !io.isNotFound(error)) {
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (mode == 'check' || base !== undefined) validate(base);
|
|
126
|
+
}
|
|
127
|
+
return base;
|
|
128
|
+
};
|
|
129
|
+
await readBase();
|
|
130
|
+
let context = await (options.host ?? host)();
|
|
131
|
+
// Only a check or an acceptance is judged, so only they sample the box.
|
|
132
|
+
let sampled = mode == 'run' || options.figure == 'cpu' ? {
|
|
133
|
+
...context,
|
|
134
|
+
busy: undefined
|
|
135
|
+
} : context;
|
|
136
|
+
let runs = [];
|
|
137
|
+
for(let i = 0; i < repeats; i++){
|
|
138
|
+
runs.push(await measure(suite, rounds, sampled, exclusive, options.figure));
|
|
139
|
+
}
|
|
140
|
+
// A different acceptance may have banked while our rounds yielded. Read its
|
|
141
|
+
// baseline under the publication lock before comparing or moving the best.
|
|
142
|
+
let readLocal = async ()=>{
|
|
143
|
+
try {
|
|
144
|
+
let local = JSON.parse(await store.read(options.local));
|
|
145
|
+
validate(local);
|
|
146
|
+
return local;
|
|
147
|
+
} catch (error) {
|
|
148
|
+
if (!io.isNotFound(error)) throw error;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
let current = await exclusive(async ()=>{
|
|
152
|
+
let base = await readBase();
|
|
153
|
+
let current = best(runs);
|
|
154
|
+
// A baseline banked on another runtime or CPU is no reference for this
|
|
155
|
+
// box. A check judges by the one this box banked on its own, and without
|
|
156
|
+
// one the run is measured, not judged, and banks as that baseline.
|
|
157
|
+
let elsewhere = (base)=>base && [
|
|
158
|
+
'runtime',
|
|
159
|
+
'cpu'
|
|
160
|
+
].includes(incomparable(base, current) ?? '');
|
|
161
|
+
let banked = elsewhere(base) && mode == 'check' && options.local ? await readLocal() : undefined;
|
|
162
|
+
if (banked && !incomparable(banked, current)) base = banked;
|
|
163
|
+
current.tolerance = mode == 'accept' ? options.tolerance : base?.tolerance ?? null;
|
|
164
|
+
if (mode == 'accept' && !insufficient(current)) {
|
|
165
|
+
current.verdict = loaded(current) ? 'loaded' : 'accepted';
|
|
166
|
+
}
|
|
167
|
+
if (elsewhere(base) && mode == 'check' && !insufficient(current)) {
|
|
168
|
+
current.verdict = 'measured';
|
|
169
|
+
let bank = options.local && !loaded(current);
|
|
170
|
+
if (bank) await store.write(options.local, rebased(base, current));
|
|
171
|
+
console.error(`${current.suite}: baseline banked on ${base.runtime}, ${base.cpu}; measured on ${current.runtime}, ${current.cpu}${bank ? `, banked as its baseline here in ${options.local}` : ''}`);
|
|
172
|
+
} else if (base && mode == 'check' && !insufficient(current)) {
|
|
173
|
+
current.regressions = compare(base, current, options.coverage);
|
|
174
|
+
current.verdict = current.regressions.length ? loaded(current) ? 'loaded' : 'regressed' : covered(base, current) ? 'passed' : 'measured';
|
|
175
|
+
}
|
|
176
|
+
// An exact acceptance banks the suite as measured: a baseline banked on
|
|
177
|
+
// another runtime or workload, or for benches the suite no longer has, is
|
|
178
|
+
// no reference for it.
|
|
179
|
+
let previous = !base ? undefined : options.coverage == 'subset' ? base : incomparable(base, current) ? undefined : {
|
|
180
|
+
...base,
|
|
181
|
+
benches: base.benches.filter((b)=>current.benches.some((c)=>c.name == b.name))
|
|
182
|
+
};
|
|
183
|
+
await store.write(options.output, current);
|
|
184
|
+
// A loaded run is kept as measured; baseline() refuses to bank it.
|
|
185
|
+
if (mode == 'accept' && !insufficient(current)) {
|
|
186
|
+
await store.write(options.baseline, baseline(runs, options.tolerance, previous, options.slower));
|
|
187
|
+
}
|
|
188
|
+
return current;
|
|
189
|
+
});
|
|
190
|
+
let report = [];
|
|
191
|
+
try {
|
|
192
|
+
report = await (options.reporters ?? reporters)(context);
|
|
193
|
+
} catch (error) {
|
|
194
|
+
console.error('Benchmark reporter factory failed', error);
|
|
195
|
+
}
|
|
196
|
+
if (report.length) {
|
|
197
|
+
// Reporting owns an immutable snapshot, never the ratchet's mutable result.
|
|
198
|
+
let snapshot = freeze(JSON.parse(JSON.stringify(current)));
|
|
199
|
+
// One broken provider cannot keep another from receiving the durable run.
|
|
200
|
+
let deliveries = await Promise.allSettled(report.map((send)=>Promise.resolve().then(()=>send(snapshot))));
|
|
201
|
+
for (let delivery of deliveries){
|
|
202
|
+
if (delivery.status == 'rejected') {
|
|
203
|
+
console.error('Benchmark reporter failed', delivery.reason);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (current.verdict == 'regressed') throw new Regressed(current);
|
|
208
|
+
return current;
|
|
209
|
+
};
|
|
210
|
+
/** One run: every round of every bench, aggregated, with the host's metadata.
|
|
211
|
+
* The ratchet's verdict is the caller's. */ let measure = async (suite, rounds, context, exclusive, figure)=>{
|
|
212
|
+
let benches = suite.benches.map((b)=>({
|
|
213
|
+
name: b.name,
|
|
214
|
+
unit: b.unit,
|
|
215
|
+
...b.resolution !== undefined ? {
|
|
216
|
+
resolution: b.resolution
|
|
217
|
+
} : {},
|
|
218
|
+
better: b.better ?? 'lower',
|
|
219
|
+
samples: [],
|
|
220
|
+
rounds: [],
|
|
221
|
+
median: 0,
|
|
222
|
+
spread: 0,
|
|
223
|
+
spans: null
|
|
224
|
+
}));
|
|
225
|
+
// The box is sampled at rest before each round, inside the lock: the
|
|
226
|
+
// bench's own work, and what it asks of a server, never counts against it.
|
|
227
|
+
let busy = [];
|
|
228
|
+
for(let round = 0; round < rounds; round++){
|
|
229
|
+
await exclusive(async ()=>{
|
|
230
|
+
let use = await context.busy?.();
|
|
231
|
+
if (use !== undefined) busy.push(use);
|
|
232
|
+
let collected = 'collect' in suite ? await suite.collect(round) : undefined;
|
|
233
|
+
if (collected) {
|
|
234
|
+
sameNames(suite.benches, Object.keys(collected).map((name)=>({
|
|
235
|
+
name,
|
|
236
|
+
unit: 'collected'
|
|
237
|
+
})));
|
|
238
|
+
}
|
|
239
|
+
for(let i = 0; i < benches.length; i++){
|
|
240
|
+
let b = benches[i];
|
|
241
|
+
let input = collected ? collected[b.name] : await suite.benches[i].sample(round);
|
|
242
|
+
let raw = samples(input);
|
|
243
|
+
if (figure && raw.some((s)=>s.cpu === undefined)) {
|
|
244
|
+
throw new Error(`Missing CPU measurement: ${b.name}`);
|
|
245
|
+
}
|
|
246
|
+
let measured = (s)=>figure ? s.cpu : s.value;
|
|
247
|
+
b.samples.push(...raw.map(({ spans: _spans, ...s })=>({
|
|
248
|
+
...s,
|
|
249
|
+
round
|
|
250
|
+
})));
|
|
251
|
+
let middle = [
|
|
252
|
+
...raw
|
|
253
|
+
].sort((a, b)=>measured(a) - measured(b))[Math.floor(raw.length / 2)];
|
|
254
|
+
let cpu = raw.map((s)=>s.cpu);
|
|
255
|
+
b.rounds.push({
|
|
256
|
+
index: round,
|
|
257
|
+
median: median(raw.map(measured)),
|
|
258
|
+
...cpu.every((n)=>n !== undefined) ? {
|
|
259
|
+
cpu: median(cpu)
|
|
260
|
+
} : {},
|
|
261
|
+
spans: middle.spans ?? null
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
for (let b of benches){
|
|
267
|
+
b.median = median(b.rounds.map((r)=>r.median));
|
|
268
|
+
b.spread = spread(b.rounds.map((r)=>r.median), b.better);
|
|
269
|
+
let middle = [
|
|
270
|
+
...b.rounds
|
|
271
|
+
].sort((a, b)=>a.median - b.median)[Math.floor(rounds / 2)];
|
|
272
|
+
b.spans = middle.spans;
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
version: 1,
|
|
276
|
+
suite: suite.name,
|
|
277
|
+
metric: figure ? `${suite.metric}/cpu` : suite.metric,
|
|
278
|
+
workload: suite.workload,
|
|
279
|
+
at: new Date().toISOString(),
|
|
280
|
+
commit: context.commit,
|
|
281
|
+
runtime: context.runtime,
|
|
282
|
+
cpu: context.cpu,
|
|
283
|
+
load: [
|
|
284
|
+
...context.load
|
|
285
|
+
],
|
|
286
|
+
busy: busy.length ? Math.max(...busy) : null,
|
|
287
|
+
rounds,
|
|
288
|
+
benches,
|
|
289
|
+
tolerance: null,
|
|
290
|
+
verdict: insufficient({
|
|
291
|
+
benches
|
|
292
|
+
}) ? 'inconclusive' : 'measured',
|
|
293
|
+
regressions: []
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
let freeze = (input)=>{
|
|
297
|
+
if (input && typeof input == 'object') {
|
|
298
|
+
Object.freeze(input);
|
|
299
|
+
for (let value of Object.values(input))freeze(value);
|
|
300
|
+
}
|
|
301
|
+
return input;
|
|
302
|
+
};
|
|
303
|
+
//# sourceMappingURL=runner.js.map
|
package/runner.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sources":["./runner.ts"],"names":[],"mappings":"AAAA,YAAY,6BAAkC;AAC9C,YAAY,wCAA6C;AACzD;;0CAE0C,GAC1C,SAAoB,IAAI,EAAkB,SAAS,oBAAmB;AACtE,SAAS,OAAO,EAAE,OAAO,QAAQ,YAAW;AAC5C,SAGE,YAAY,EACZ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