@mark1russell7/rigor-bench 0.2.11 → 0.2.13
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 +34 -1
- package/build/index.d.ts +64 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +119 -4
- package/build/index.js.map +1 -1
- package/build/supervise.d.ts +8 -1
- package/build/supervise.d.ts.map +1 -1
- package/build/supervise.js +12 -5
- package/build/supervise.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -43,6 +43,8 @@ v.comparison; // the cases that gain and dro
|
|
|
43
43
|
| `caseIntervals(records, level)` | The ratio of each case with a distribution-free interval of its median over the rounds. The level 0.95 needs 6 rounds or more. |
|
|
44
44
|
| `limitVerdict(candidate, aa, options)` | The verdict of the claim "the ratio of each case is at most `limit`": `within`, `beyond` or `cannot decide`. |
|
|
45
45
|
| `budgetVerdict(rounds, aa, options)` | The verdict of the claim "the median of each case is at most `limit`", for one build: `within`, `beyond` or `cannot decide`. |
|
|
46
|
+
| `budgetLooksVerdict(rounds, aa, options)` | The budget verdict of a run that adds rounds to the cases with no outcome, up to a stated budget. |
|
|
47
|
+
| `budgetLookSpend(looks)` | The chance of error that a list of looks spends. |
|
|
46
48
|
| `timeRounds(arms, options)` | The timed rounds of one case in one process: a warm-up, a batch of at least the target time, and the order of `firstArm`. |
|
|
47
49
|
| `verdictPower(options)` | The share of each outcome over seeded benches with a known ratio: the power test of a rule. |
|
|
48
50
|
| `balanceOrders(records)` | The records of each case with a turned order. It removes the extra records of the larger order, with the highest rounds first. |
|
|
@@ -93,6 +95,37 @@ v.cases; // the medians, the interval,
|
|
|
93
95
|
- The level 0.95 needs 6 rounds or more in each arm. With fewer rounds, the case is `cannot decide`.
|
|
94
96
|
- A case is `within` when the high end of the interval of its median is at most the limit. A case is `beyond` when the low end is above the limit.
|
|
95
97
|
|
|
98
|
+
### Add rounds up to a budget
|
|
99
|
+
|
|
100
|
+
Six rounds give an interval from the lowest to the highest value. One slow load makes the case `cannot decide`, and a rerun hides this. `budgetLooksVerdict` adds rounds to the cases with no outcome:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
let v = budgetLooksVerdict(rounds, aaRounds, { limit: 450, maxDifference: 200 });
|
|
104
|
+
while (v.more.length > 0) {
|
|
105
|
+
// Add rounds to both arms, so each case in v.more has its v.more[i].rounds.
|
|
106
|
+
v = budgetLooksVerdict(rounds, aaRounds, { limit: 450, maxDifference: 200 });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
v.fails; // true only when an interval is above the limit
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
- `BUDGET_LOOKS` has looks at 6, 12 and 24 rounds. The interval of 6 rounds is the same as in `budgetVerdict`.
|
|
113
|
+
- Each extra look at the data adds a chance of error. The levels of the looks are high, so the sum of the chances is 0.0442, under the overall 0.05.
|
|
114
|
+
- The sum comes from the real coverage of each interval, not from the nominal level. A list that spends more than the overall level gives a `RangeError`.
|
|
115
|
+
- Each coverage needs independent rounds. This limit stays: a slow computer for one whole run moves all its rounds.
|
|
116
|
+
- The first look with an outcome decides a case. Later rounds of the case do not change it.
|
|
117
|
+
- A final `cannot decide` does not fail. Show it to the reader of the run. A median near the limit can have this outcome.
|
|
118
|
+
|
|
119
|
+
We tested the default looks by resampling 48 blocking times of a noisy web page, with the median moved. Each row has 20000 seeded runs, and the limit is 450.
|
|
120
|
+
|
|
121
|
+
| True median | Six rounds: outcome `beyond` | Looks: outcome `beyond` | Looks: final `cannot decide` | Mean rounds |
|
|
122
|
+
| ---: | ---: | ---: | ---: | ---: |
|
|
123
|
+
| 300 | 0% | 0% | 0% | 6.9 |
|
|
124
|
+
| 376 | 0% | 0% | 2.8% | 12.4 |
|
|
125
|
+
| 450 | 1.5% | 2.0% | 96.1% | 23.4 |
|
|
126
|
+
| 500 | 38.6% | 89.0% | 11.0% | 15.1 |
|
|
127
|
+
| 550 | 44.6% | 93.9% | 6.1% | 13.8 |
|
|
128
|
+
|
|
96
129
|
## A claim at each size: the ladder
|
|
97
130
|
|
|
98
131
|
A ladder is the scale plan of a product, as data. It has rungs at sizes that grow, for example 1, 10 and 100 tenants. Each rung has budgets, and it names the test that holds it. A number in a document is not a rung: a rung is held only when a record of its test shows each budget `within`.
|
|
@@ -232,7 +265,7 @@ const result = await superviseCases({
|
|
|
232
265
|
The child calls `caseProgress(file).start(id, stage)` before each stage, and `end(id)` after the result is on the disk.
|
|
233
266
|
|
|
234
267
|
- A stage over its budget gives `over-budget`. This time is a lower bound, so a statistic treats it as censored, not as a value. The next child runs the cases that are left.
|
|
235
|
-
- After 2 overruns in one group (the option `overruns`), each other case of the group gives `not-run`, with the ids of the 2 overruns. An overrun is measured, and a skip is not. Keep these tags different.
|
|
268
|
+
- After 2 overruns in one group (the option `overruns`), each other case of the group gives `not-run`, with the ids of the 2 overruns. When cases have a `rank`, for example an input size, the count is for each rank. The stop is for that rank and above, and a smaller rank goes on. An overrun is measured, and a skip is not. Keep these tags different.
|
|
236
269
|
- An overrun counts for the group of its stage only. A slow router thus does not count against the packer of its cases.
|
|
237
270
|
- A case in `done` does not run, so a resume runs no case two times.
|
|
238
271
|
- The option `earlier` takes the ends of a stopped run. Its overruns count for their groups, so a stop and a resume give the same ends as a run with no stop. Keep each case in `cases`, and put the ids of the finished cases in `done`.
|
package/build/index.d.ts
CHANGED
|
@@ -61,6 +61,69 @@ interface BudgetVerdict {
|
|
|
61
61
|
* - Each other verdict is `cannot decide`, and so is a verdict with no cases.
|
|
62
62
|
*/
|
|
63
63
|
export declare function budgetVerdict(rounds: readonly BudgetRound[], aa: readonly BudgetRound[], options: BudgetOptions): BudgetVerdict;
|
|
64
|
+
/** One look of a budget with looks: the rounds of each arm, and the level of the interval at those rounds. */
|
|
65
|
+
interface BudgetLook {
|
|
66
|
+
readonly rounds: number;
|
|
67
|
+
readonly level: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* These looks start with 6 rounds, as `budgetVerdict` does, and they stop at 24. The three looks spend 0.0442 of the
|
|
71
|
+
* overall 0.05. On the blocking times of a noisy web page, 97% of the runs with a median 16% under the limit stop by 24.
|
|
72
|
+
*/
|
|
73
|
+
export declare const BUDGET_LOOKS: readonly BudgetLook[];
|
|
74
|
+
/** The options of a budget verdict with looks. */
|
|
75
|
+
interface BudgetLooksOptions {
|
|
76
|
+
/** The largest median that the claim permits, in the unit of the values. */
|
|
77
|
+
readonly limit: number;
|
|
78
|
+
/** The largest difference between the medians of the two arms of the same build. */
|
|
79
|
+
readonly maxDifference: number;
|
|
80
|
+
/** The looks, with the rounds in rising order. The default is `BUDGET_LOOKS`. */
|
|
81
|
+
readonly looks?: readonly BudgetLook[];
|
|
82
|
+
/** The level over all looks of one case. The default is 0.95. */
|
|
83
|
+
readonly level?: number;
|
|
84
|
+
}
|
|
85
|
+
/** The next look of one case: the rounds that each arm of the case needs. */
|
|
86
|
+
interface BudgetMore {
|
|
87
|
+
readonly case: string;
|
|
88
|
+
readonly rounds: number;
|
|
89
|
+
}
|
|
90
|
+
/** A budget verdict with looks. The field `level` is the level over all looks. */
|
|
91
|
+
interface BudgetLooksVerdict extends BudgetVerdict {
|
|
92
|
+
/** The chance of error that the looks spend: the sum of 1 - coverage over the looks. */
|
|
93
|
+
readonly spent: number;
|
|
94
|
+
/** The cases with no outcome that can have another look. The list is empty when the verdict is final. */
|
|
95
|
+
readonly more: readonly BudgetMore[];
|
|
96
|
+
/** True only when the interval of a case is above the limit. A case with no outcome at the last look does not fail. */
|
|
97
|
+
readonly fails: boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* This function gives the chance of error that a list of looks spends: the sum of 1 - coverage of each look. This sum is
|
|
101
|
+
* the Bonferroni bound over the looks. A look that has too few rounds for its level gives a `RangeError`.
|
|
102
|
+
*/
|
|
103
|
+
export declare function budgetLookSpend(looks: readonly BudgetLook[]): number;
|
|
104
|
+
/**
|
|
105
|
+
* This function gives the budget verdict of a run that adds rounds. A caller gives all rounds so far, and it gets a
|
|
106
|
+
* verdict and the field `more`. It adds the rounds of `more` to both arms, and it calls the function again.
|
|
107
|
+
*
|
|
108
|
+
* The chance of error of one look is 1 - coverage. The coverage is 1 - 2 P(X <= k - 1), for X ~ Binomial(n, 1/2) and
|
|
109
|
+
* the rank k of the interval. The nominal level does not give this chance. The default looks have these figures:
|
|
110
|
+
*
|
|
111
|
+
* | Rounds n | Level | Rank k | Coverage | Chance of error |
|
|
112
|
+
* | ---: | ---: | ---: | ---: | ---: |
|
|
113
|
+
* | 6 | 0.95 | 1 | 0.96875 | 0.03125 |
|
|
114
|
+
* | 12 | 0.99 | 2 | 0.99365 | 0.00635 |
|
|
115
|
+
* | 24 | 0.99 | 6 | 0.99339 | 0.00661 |
|
|
116
|
+
* | Sum | | | | 0.04421 |
|
|
117
|
+
*
|
|
118
|
+
* The sum is the Bonferroni bound over the looks. Each coverage needs independent rounds. Rounds with a shared cause, for
|
|
119
|
+
* example a slow computer for one run, do not have that coverage.
|
|
120
|
+
*
|
|
121
|
+
* - The first look of a case with an outcome decides the case. Later rounds do not change it.
|
|
122
|
+
* - Each look reads the rounds of that look in the order of their numbers. Thus a verdict comes again from its records.
|
|
123
|
+
* - A sum of `budgetLookSpend` above 1 - `level` gives a `RangeError`, because many looks at one level spend too much.
|
|
124
|
+
* - The field `fails` is true only for the outcome `beyond`. Tell a final `cannot decide` to the reader of the run.
|
|
125
|
+
*/
|
|
126
|
+
export declare function budgetLooksVerdict(rounds: readonly BudgetRound[], aa: readonly BudgetRound[], options: BudgetLooksOptions): BudgetLooksVerdict;
|
|
64
127
|
/** One time of the control in one group. */
|
|
65
128
|
interface ControlRow {
|
|
66
129
|
/** The name of the group: a run, or a shard of one run. */
|
|
@@ -697,5 +760,5 @@ interface Rounds {
|
|
|
697
760
|
* keeps the work.
|
|
698
761
|
*/
|
|
699
762
|
export declare function timeRounds(arms: Readonly<Record<Arm, () => number>>, options: RoundsOptions): Rounds;
|
|
700
|
-
export { type Arm, type Balanced, type Band, type BandKind, type BandOptions, type BudgetOptions, type BudgetOutcome, type BudgetResult, type BudgetRound, type BudgetVerdict, type CaseBudget, type CaseInterval, type CaseLimit, type CaseRatio, type ControlFactors, type ControlOptions, type ControlRow, type GroupCounts, type GroupFactor, type JobLimitVerdict, type JobRecords, type JobVerdict, type Ladder, type LadderDimension, type LadderOptions, type LadderVerdict, type LimitOptions, type LimitOutcome, type LimitVerdict, type MeasuredFactor, type MedianBudget, type NoFactor, type NoiseCheck, type PairedTime, type PoolFacts, type PoolOptions, type PooledJob, type PooledLimitVerdict, type PooledRecords, type PooledVerdict, type Power, type PowerOptions, type QuantileBudget, type RateBudget, type Rounds, type RoundsOptions, type RunPairs, type Rung, type RungBudget, type RungEvidence, type RungRecord, type RungVerdict, type TimeOutcome, type TimeVerdict, type VerdictOptions, type VerdictRule, type WorstBudget, caseRatios, checkPairedTime, firstArm };
|
|
763
|
+
export { type Arm, type Balanced, type Band, type BandKind, type BandOptions, type BudgetLook, type BudgetLooksOptions, type BudgetLooksVerdict, type BudgetMore, type BudgetOptions, type BudgetOutcome, type BudgetResult, type BudgetRound, type BudgetVerdict, type CaseBudget, type CaseInterval, type CaseLimit, type CaseRatio, type ControlFactors, type ControlOptions, type ControlRow, type GroupCounts, type GroupFactor, type JobLimitVerdict, type JobRecords, type JobVerdict, type Ladder, type LadderDimension, type LadderOptions, type LadderVerdict, type LimitOptions, type LimitOutcome, type LimitVerdict, type MeasuredFactor, type MedianBudget, type NoFactor, type NoiseCheck, type PairedTime, type PoolFacts, type PoolOptions, type PooledJob, type PooledLimitVerdict, type PooledRecords, type PooledVerdict, type Power, type PowerOptions, type QuantileBudget, type RateBudget, type Rounds, type RoundsOptions, type RunPairs, type Rung, type RungBudget, type RungEvidence, type RungRecord, type RungVerdict, type TimeOutcome, type TimeVerdict, type VerdictOptions, type VerdictRule, type WorstBudget, caseRatios, checkPairedTime, firstArm };
|
|
701
764
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/budget.ts","../src/control.ts","../src/ladder.ts","../src/verdict.ts","../src/limit.ts","../src/merge.ts","../src/power.ts","../src/rounds.ts"],"mappings":";;;UAQiB;;WAEN;;WAEA;WACA;;;KAIC;;UAGK;;WAEN;;WAEA;;WAEA;;;UAIM;WACN;;WAEA;;WAEA;WACA;;WAEA;;WAEA;;WAEA;WACA;;WAEA;WACA,SAAS;;WAET;;;UAIM;WACN,SAAS;;WAET;WACA;WACA;WACA;WACA,gBAAgB;;;;;;;;;;;;wBAyDX,cAAc,iBAAiB,eAAe,aAAa,eAAe,SAAS,gBAAgB;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/budget.ts","../src/control.ts","../src/ladder.ts","../src/verdict.ts","../src/limit.ts","../src/merge.ts","../src/power.ts","../src/rounds.ts"],"mappings":";;;UAQiB;;WAEN;;WAEA;WACA;;;KAIC;;UAGK;;WAEN;;WAEA;;WAEA;;;UAIM;WACN;;WAEA;;WAEA;WACA;;WAEA;;WAEA;;WAEA;WACA;;WAEA;WACA,SAAS;;WAET;;;UAIM;WACN,SAAS;;WAET;WACA;WACA;WACA;WACA,gBAAgB;;;;;;;;;;;;wBAyDX,cAAc,iBAAiB,eAAe,aAAa,eAAe,SAAS,gBAAgB;;UAyBlG;WACN;WACA;;;;;;qBAOE,uBAAuB;;UAOnB;;WAEN;;WAEA;;WAEA,iBAAiB;;WAEjB;;;UAIM;WACN;WACA;;;UAIM,2BAA2B;;WAEjC;;WAEA,eAAe;;WAEf;;;;;;wBAOK,gBAAgB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;wBAoDhC,mBAAmB,iBAAiB,eAAe,aAAa,eAAe,SAAS,qBAAqB;;UCxO5G;;WAEN;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;;UAIM;WACN;;WAEA;;WAEA;;WAEA;;;UAIM,uBAAuB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iBAAsB;;UASzE;WACN;WACA,SAAS;;;UAIH;;WAEN,SAAS;;WAET,QAAQ;;WAER,eAAe;;WAEf;;WAEA;;WAEA;;WAEA;;;;;;;;wBAWK,mBAAmB,eAAe,cAAc,SAAS,eAAe;;UASvE;WACN,OAAO,SAAS,wBAAwB;;;;;;wBAOnC,YAAY,KAAK,UAAU,gBAAgB,UAAS,iBAAsB,eAAe;;UC/NxF;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA,UAAU;;;UAIJ;WACN;WACA,UAAU,SAAS,OAAO;;;;;;WAM1B;;;;;;wBAOK,aAAa,SAAS,eAAe;;UClCpC;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;WACN,SAAS;;WAET;;WAEA;;;;;;;wBAQK,WAAW,MAAM,SAAS,OAAO,qBAAqB,SAAS,gBAAgB"}
|
package/build/index.js
CHANGED
|
@@ -66,11 +66,16 @@ function budgetVerdict(rounds, aa, options) {
|
|
|
66
66
|
if (!(maxDifference >= 0 && Number.isFinite(maxDifference))) throw new RangeError(`budgetVerdict: the largest difference is finite and 0 or more, not ${maxDifference}.`);
|
|
67
67
|
const values = valuesOfCases("the rounds", rounds);
|
|
68
68
|
const aaValues = valuesOfCases("the A/A arm", aa);
|
|
69
|
-
|
|
70
|
-
const facts = {
|
|
69
|
+
return verdictOf([...values.keys()].sort().map((name) => caseBudget(name, values.get(name) ?? [], aaValues.get(name) ?? [], options, level)), {
|
|
71
70
|
limit,
|
|
72
71
|
maxDifference,
|
|
73
|
-
level
|
|
72
|
+
level
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/** This function gives the verdict of a list of case verdicts. */
|
|
76
|
+
function verdictOf(cases, claim) {
|
|
77
|
+
const facts = {
|
|
78
|
+
...claim,
|
|
74
79
|
cases
|
|
75
80
|
};
|
|
76
81
|
if (cases.length === 0) return {
|
|
@@ -94,6 +99,116 @@ function budgetVerdict(rounds, aa, options) {
|
|
|
94
99
|
...facts
|
|
95
100
|
};
|
|
96
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* These looks start with 6 rounds, as `budgetVerdict` does, and they stop at 24. The three looks spend 0.0442 of the
|
|
104
|
+
* overall 0.05. On the blocking times of a noisy web page, 97% of the runs with a median 16% under the limit stop by 24.
|
|
105
|
+
*/
|
|
106
|
+
const BUDGET_LOOKS = [
|
|
107
|
+
{
|
|
108
|
+
rounds: 6,
|
|
109
|
+
level: .95
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
rounds: 12,
|
|
113
|
+
level: .99
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
rounds: 24,
|
|
117
|
+
level: .99
|
|
118
|
+
}
|
|
119
|
+
];
|
|
120
|
+
/**
|
|
121
|
+
* This function gives the chance of error that a list of looks spends: the sum of 1 - coverage of each look. This sum is
|
|
122
|
+
* the Bonferroni bound over the looks. A look that has too few rounds for its level gives a `RangeError`.
|
|
123
|
+
*/
|
|
124
|
+
function budgetLookSpend(looks) {
|
|
125
|
+
if (looks.length === 0) throw new RangeError("budgetLookSpend: the list of looks is empty.");
|
|
126
|
+
let spent = 0;
|
|
127
|
+
let last = 0;
|
|
128
|
+
for (const { rounds, level } of looks) {
|
|
129
|
+
if (!(Number.isInteger(rounds) && rounds > last)) throw new RangeError(`budgetLookSpend: the rounds of the looks are whole numbers in rising order, not ${rounds} after ${last}.`);
|
|
130
|
+
const { coverage } = medianInterval(Array.from({ length: rounds }, (_, i) => i), level);
|
|
131
|
+
if (coverage < level) throw new RangeError(`budgetLookSpend: ${rounds} rounds are too few for the level ${level}.`);
|
|
132
|
+
spent += 1 - coverage;
|
|
133
|
+
last = rounds;
|
|
134
|
+
}
|
|
135
|
+
return spent;
|
|
136
|
+
}
|
|
137
|
+
/** This function gives the outcome of one case: the first look with an outcome, or the last look that the rounds reach. */
|
|
138
|
+
function caseAtLooks(name, values, aaValues, options, looks) {
|
|
139
|
+
let verdict;
|
|
140
|
+
for (const { rounds, level } of looks) {
|
|
141
|
+
if (values.length < rounds || aaValues.length < rounds) return {
|
|
142
|
+
verdict: verdict ?? caseBudget(name, values, aaValues, options, level),
|
|
143
|
+
next: rounds
|
|
144
|
+
};
|
|
145
|
+
verdict = caseBudget(name, values.slice(0, rounds), aaValues.slice(0, rounds), options, level);
|
|
146
|
+
if (verdict.outcome !== "cannot decide") return {
|
|
147
|
+
verdict,
|
|
148
|
+
next: void 0
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
verdict,
|
|
153
|
+
next: void 0
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* This function gives the budget verdict of a run that adds rounds. A caller gives all rounds so far, and it gets a
|
|
158
|
+
* verdict and the field `more`. It adds the rounds of `more` to both arms, and it calls the function again.
|
|
159
|
+
*
|
|
160
|
+
* The chance of error of one look is 1 - coverage. The coverage is 1 - 2 P(X <= k - 1), for X ~ Binomial(n, 1/2) and
|
|
161
|
+
* the rank k of the interval. The nominal level does not give this chance. The default looks have these figures:
|
|
162
|
+
*
|
|
163
|
+
* | Rounds n | Level | Rank k | Coverage | Chance of error |
|
|
164
|
+
* | ---: | ---: | ---: | ---: | ---: |
|
|
165
|
+
* | 6 | 0.95 | 1 | 0.96875 | 0.03125 |
|
|
166
|
+
* | 12 | 0.99 | 2 | 0.99365 | 0.00635 |
|
|
167
|
+
* | 24 | 0.99 | 6 | 0.99339 | 0.00661 |
|
|
168
|
+
* | Sum | | | | 0.04421 |
|
|
169
|
+
*
|
|
170
|
+
* The sum is the Bonferroni bound over the looks. Each coverage needs independent rounds. Rounds with a shared cause, for
|
|
171
|
+
* example a slow computer for one run, do not have that coverage.
|
|
172
|
+
*
|
|
173
|
+
* - The first look of a case with an outcome decides the case. Later rounds do not change it.
|
|
174
|
+
* - Each look reads the rounds of that look in the order of their numbers. Thus a verdict comes again from its records.
|
|
175
|
+
* - A sum of `budgetLookSpend` above 1 - `level` gives a `RangeError`, because many looks at one level spend too much.
|
|
176
|
+
* - The field `fails` is true only for the outcome `beyond`. Tell a final `cannot decide` to the reader of the run.
|
|
177
|
+
*/
|
|
178
|
+
function budgetLooksVerdict(rounds, aa, options) {
|
|
179
|
+
const { limit, maxDifference } = options;
|
|
180
|
+
const looks = options.looks ?? BUDGET_LOOKS;
|
|
181
|
+
const level = options.level ?? .95;
|
|
182
|
+
const spent = budgetLookSpend(looks);
|
|
183
|
+
if (spent > 1 - level) throw new RangeError(`budgetLooksVerdict: the looks spend ${round$2(spent)}, over the ${round$2(1 - level)} of the level ${level}.`);
|
|
184
|
+
if (!(limit >= 0 && Number.isFinite(limit))) throw new RangeError(`budgetLooksVerdict: the limit is finite and 0 or more, not ${limit}.`);
|
|
185
|
+
if (!(maxDifference >= 0 && Number.isFinite(maxDifference))) throw new RangeError(`budgetLooksVerdict: the largest difference is finite and 0 or more, not ${maxDifference}.`);
|
|
186
|
+
const byRound = (list) => [...list].sort((a, b) => a.round - b.round);
|
|
187
|
+
const values = valuesOfCases("the rounds", byRound(rounds));
|
|
188
|
+
const aaValues = valuesOfCases("the A/A arm", byRound(aa));
|
|
189
|
+
const results = [...values.keys()].sort().map((name) => ({
|
|
190
|
+
name,
|
|
191
|
+
...caseAtLooks(name, values.get(name) ?? [], aaValues.get(name) ?? [], {
|
|
192
|
+
limit,
|
|
193
|
+
maxDifference
|
|
194
|
+
}, looks)
|
|
195
|
+
}));
|
|
196
|
+
const verdict = verdictOf(results.map((r) => r.verdict), {
|
|
197
|
+
limit,
|
|
198
|
+
maxDifference,
|
|
199
|
+
level
|
|
200
|
+
});
|
|
201
|
+
const more = results.flatMap((r) => r.next === void 0 ? [] : [{
|
|
202
|
+
case: r.name,
|
|
203
|
+
rounds: r.next
|
|
204
|
+
}]);
|
|
205
|
+
return {
|
|
206
|
+
...verdict,
|
|
207
|
+
spent,
|
|
208
|
+
more,
|
|
209
|
+
fails: verdict.cases.some((c) => c.outcome === "beyond")
|
|
210
|
+
};
|
|
211
|
+
}
|
|
97
212
|
function round$2(x) {
|
|
98
213
|
return Math.round(x * 1e4) / 1e4;
|
|
99
214
|
}
|
|
@@ -1088,6 +1203,6 @@ function timeRounds(arms, options) {
|
|
|
1088
1203
|
sink
|
|
1089
1204
|
};
|
|
1090
1205
|
}
|
|
1091
|
-
export { LADDER_FORMAT, aaBand, aaSpread, armVerdicts, balanceOrders, budgetVerdict, caseIntervals, caseRatios, checkLadder, checkPairedTime, controlFactor, firstArm, ladderVerdict, limitVerdict, poolRecords, pooledBand, pooledLimitVerdict, pooledVerdict, rungVerdict, timeRounds, timeVerdict, verdictMargin, verdictPower };
|
|
1206
|
+
export { BUDGET_LOOKS, LADDER_FORMAT, aaBand, aaSpread, armVerdicts, balanceOrders, budgetLookSpend, budgetLooksVerdict, budgetVerdict, caseIntervals, caseRatios, checkLadder, checkPairedTime, controlFactor, firstArm, ladderVerdict, limitVerdict, poolRecords, pooledBand, pooledLimitVerdict, pooledVerdict, rungVerdict, timeRounds, timeVerdict, verdictMargin, verdictPower };
|
|
1092
1207
|
|
|
1093
1208
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["round","round"],"sources":["../src/budget.ts","../src/control.ts","../src/ladder.ts","../src/verdict.ts","../src/limit.ts","../src/merge.ts","../src/power.ts","../src/rounds.ts"],"sourcesContent":["/**\n * The budget verdict of one build: is the median of a measure of each case at most an absolute limit? An example is the\n * claim \"the median blocking time of this page is at most 450 ms\". The time verdict and the limit verdict judge a ratio\n * of two arms, so they cannot use a value of 0. Their A/A band is also a ratio.\n */\nimport { median, medianInterval } from \"@mark1russell7/rigor-statistics\";\n\n/** One value of one build on one case. The value is finite and 0 or more. */\nexport interface BudgetRound {\n /** The name of the case: one input of the bench. */\n readonly case: string;\n /** The number of the round, a whole number of 0 or more. */\n readonly round: number;\n readonly value: number;\n}\n\n/** The three outcomes of a budget verdict. */\nexport type BudgetOutcome = \"within\" | \"beyond\" | \"cannot decide\";\n\n/** The options of a budget verdict. */\nexport interface BudgetOptions {\n /** The largest median that the claim permits, in the unit of the values. */\n readonly limit: number;\n /** The largest difference between the medians of the two arms of the same build. A larger difference makes the run too noisy. */\n readonly maxDifference: number;\n /** The level of the interval of each median. The default is 0.95, which needs 6 rounds or more in each arm. */\n readonly caseLevel?: number;\n}\n\n/** The verdict of one case against the budget. */\nexport interface CaseBudget {\n readonly case: string;\n /** The number of rounds of the case. */\n readonly rounds: number;\n /** The number of rounds of the case in the A/A arm. */\n readonly aaRounds: number;\n readonly median: number;\n /** The median of the A/A arm, or undefined when the A/A arm does not have the case. */\n readonly aaMedian: number | undefined;\n /** The size of the difference between the two medians, or undefined when the A/A arm does not have the case. */\n readonly difference: number | undefined;\n /** The ends of the distribution-free interval of the median. */\n readonly low: number;\n readonly high: number;\n /** The coverage of the interval. Below the level, the case has too few rounds. */\n readonly coverage: number;\n readonly outcome: BudgetOutcome;\n /** The reason of the outcome, in one sentence, with the limit, the medians, the difference and the rounds. */\n readonly reason: string;\n}\n\n/** A budget verdict, with the facts that it uses. */\nexport interface BudgetVerdict {\n readonly outcome: BudgetOutcome;\n /** The reason of the outcome, in one sentence. */\n readonly reason: string;\n readonly limit: number;\n readonly maxDifference: number;\n readonly level: number;\n readonly cases: readonly CaseBudget[];\n}\n\n/** This function gives the values of each case, and it refuses a value out of range or a round that comes twice. */\nfunction valuesOfCases(name: string, rounds: readonly BudgetRound[]): Map<string, number[]> {\n const seen = new Set<string>();\n const out = new Map<string, number[]>();\n for (const r of rounds) {\n if (!(Number.isFinite(r.value) && r.value >= 0)) throw new RangeError(`budgetVerdict: the value of ${JSON.stringify(r.case)} in ${name} is finite and 0 or more, not ${r.value}.`);\n const key = JSON.stringify([r.case, r.round]);\n if (seen.has(key)) throw new RangeError(`budgetVerdict: the round ${r.round} of ${JSON.stringify(r.case)} comes twice in ${name}.`);\n seen.add(key);\n out.set(r.case, [...(out.get(r.case) ?? []), r.value]);\n }\n return out;\n}\n\n/** This function gives the verdict of one case. */\nfunction caseBudget(name: string, values: readonly number[], aaValues: readonly number[], options: BudgetOptions, level: number): CaseBudget {\n const { limit, maxDifference } = options;\n const interval = medianInterval(values, level);\n const middle = median(values);\n const aaMedian = aaValues.length > 0 ? median(aaValues) : undefined;\n const difference = aaMedian === undefined ? undefined : Math.abs(middle - aaMedian);\n const aaCoverage = aaValues.length > 0 ? medianInterval(aaValues, level).coverage : 0;\n const facts = `median ${round(middle)} of ${values.length} rounds, interval ${round(interval.low)} to ${round(interval.high)}, limit ${limit}, A/A median ${aaMedian === undefined ? \"none\" : round(aaMedian)} of ${aaValues.length} rounds, difference ${difference === undefined ? \"none\" : round(difference)}`;\n const decide = (outcome: BudgetOutcome, why: string): CaseBudget => ({\n case: name,\n rounds: values.length,\n aaRounds: aaValues.length,\n median: middle,\n aaMedian,\n difference,\n low: interval.low,\n high: interval.high,\n coverage: interval.coverage,\n outcome,\n reason: `The case ${JSON.stringify(name)} has the outcome \"${outcome}\": ${why} (${facts}).`,\n });\n if (difference === undefined) return decide(\"cannot decide\", \"the A/A arm does not have the case\");\n if (interval.coverage < level || aaCoverage < level) return decide(\"cannot decide\", `an arm has too few rounds for the level ${level}`);\n if (difference > maxDifference) return decide(\"cannot decide\", `the A/A difference is above ${maxDifference}`);\n if (interval.high <= limit) return decide(\"within\", \"the interval is at or below the limit\");\n if (interval.low > limit) return decide(\"beyond\", \"the interval is above the limit\");\n return decide(\"cannot decide\", \"the interval holds the limit\");\n}\n\n/**\n * This function gives the verdict of the claim \"the median of each case is at most `limit`\". The arm `aa` is a second\n * arm of the same build, and it shows the noise of the run as a difference. Values of 0 are valid.\n * - A case is `cannot decide` when the A/A arm does not have it, or when an arm has too few rounds for the level.\n * - A case is also `cannot decide` when the medians of the two arms differ by more than `maxDifference`.\n * - Other cases are `within` when the high end of the interval is at most the limit.\n * - They are `beyond` when the low end of the interval is above the limit.\n * - The verdict is `beyond` when a case is `beyond`, and `within` when each case is `within`.\n * - Each other verdict is `cannot decide`, and so is a verdict with no cases.\n */\nexport function budgetVerdict(rounds: readonly BudgetRound[], aa: readonly BudgetRound[], options: BudgetOptions): BudgetVerdict {\n const { limit, maxDifference } = options;\n const level = options.caseLevel ?? 0.95;\n if (!(limit >= 0 && Number.isFinite(limit))) throw new RangeError(`budgetVerdict: the limit is finite and 0 or more, not ${limit}.`);\n if (!(maxDifference >= 0 && Number.isFinite(maxDifference))) throw new RangeError(`budgetVerdict: the largest difference is finite and 0 or more, not ${maxDifference}.`);\n const values = valuesOfCases(\"the rounds\", rounds);\n const aaValues = valuesOfCases(\"the A/A arm\", aa);\n const cases = [...values.keys()].sort().map((name) => caseBudget(name, values.get(name) ?? [], aaValues.get(name) ?? [], options, level));\n const facts = { limit, maxDifference, level, cases };\n if (cases.length === 0) return { outcome: \"cannot decide\", reason: \"The verdict has no cases.\", ...facts };\n const first = cases.find((c) => c.outcome === \"beyond\") ?? cases.find((c) => c.outcome === \"cannot decide\");\n if (first === undefined) {\n const top = cases.reduce((a, b) => (b.high > a.high ? b : a));\n return { outcome: \"within\", reason: `Each of the ${cases.length} cases is within. The largest is this one: ${top.reason}`, ...facts };\n }\n const count = cases.filter((c) => c.outcome === first.outcome).length;\n return { outcome: first.outcome, reason: `${count} of ${cases.length} cases have this outcome. The first is this one: ${first.reason}`, ...facts };\n}\n\nfunction round(x: number): number {\n return Math.round(x * 10_000) / 10_000;\n}\n","/**\n * The load factor of a run, read from a control. Runs on shared machines differ by load. A change does not touch a control.\n * So the change of its time between two groups measures the machine and not the code.\n * The groups can be two runs, or the shards of one run.\n */\nimport { median, quantile } from \"@mark1russell7/rigor-statistics\";\n\n/** One time of the control in one group. */\nexport interface ControlRow {\n /** The name of the group: a run, or a shard of one run. */\n readonly group: string;\n /** The name of a class of work. The same key in two groups names equal work, so a ratio of the two measures the load. */\n readonly key: string;\n /** The time. It is finite and more than 0. */\n readonly value: number;\n /** This field is true when the run stopped the case at `value`. Thus the real time is at least `value`. */\n readonly censored?: boolean;\n}\n\n/** The options of `controlFactor`. */\nexport interface ControlOptions {\n /** The group that the factors compare with. Without it, the base of each key is the median of that key over the groups. */\n readonly base?: string;\n /** The least number of keys in a factor. A group with fewer keys has no factor. The default is 5. */\n readonly minPairs?: number;\n}\n\n/** The counts of one group, with or without a factor. */\nexport interface GroupCounts {\n readonly group: string;\n /** The number of keys that the factor reads. */\n readonly pairs: number;\n /** The number of keys that this function left out because a time of the key was censored. The factor reads low when this count is not 0. */\n readonly censored: number;\n /** The number of keys of this group that have no time to compare with, so no ratio reads them. */\n readonly unshared: number;\n}\n\n/** The factor of one group. */\nexport interface MeasuredFactor extends GroupCounts {\n /** The median ratio of the times of this group over the base. A factor of 1.6 means that this group took 1.6 times as long. */\n readonly factor: number;\n /** The quartiles of the ratios. A wide spread means that one factor does not explain the load. */\n readonly low: number;\n readonly high: number;\n}\n\n/** A group with too few usable keys. It has no factor, and the other groups keep theirs. */\nexport interface NoFactor extends GroupCounts {\n readonly factor: undefined;\n /** The reason that this group has no factor. */\n readonly reason: string;\n}\n\n/** The result of one group. Read `factor` first: a group with too few usable keys has no factor. */\nexport type GroupFactor = MeasuredFactor | NoFactor;\n\n/** The factors of a run, with the base that they use. */\nexport interface ControlFactors {\n /** The base group, or undefined when the base of each key is its median over the groups. */\n readonly base: string | undefined;\n readonly factors: readonly GroupFactor[];\n}\n\nconst DEFAULT_MIN_PAIRS = 5;\n\nfunction checkedRows(rows: readonly ControlRow[]): Map<string, Map<string, ControlRow>> {\n const groups = new Map<string, Map<string, ControlRow>>();\n for (const r of rows) {\n if (!(Number.isFinite(r.value) && r.value > 0)) throw new RangeError(`controlFactor: the value of ${JSON.stringify(r.key)} in ${JSON.stringify(r.group)} is finite and more than 0, not ${r.value}.`);\n const group = groups.get(r.group) ?? new Map<string, ControlRow>();\n if (group.has(r.key)) throw new RangeError(`controlFactor: the key ${JSON.stringify(r.key)} comes twice in ${JSON.stringify(r.group)}.`);\n group.set(r.key, r);\n groups.set(r.group, group);\n }\n return groups;\n}\n\nfunction factorOf(group: string, ratios: readonly number[], censored: number, unshared: number, minPairs: number): GroupFactor {\n const counts = { group, pairs: ratios.length, censored, unshared };\n if (ratios.length < minPairs) return { ...counts, factor: undefined, reason: `the group ${JSON.stringify(group)} has ${ratios.length} usable keys, and the least is ${minPairs}.` };\n return { ...counts, factor: median(ratios), low: quantile(ratios, 0.25), high: quantile(ratios, 0.75) };\n}\n\n/** This function refuses a result with no factor at all, because such a result measures nothing. */\nfunction withFactors(base: string | undefined, factors: readonly GroupFactor[]): ControlFactors {\n if (factors.every((f) => f.factor === undefined)) {\n const thin = factors.find((f): f is NoFactor => f.factor === undefined);\n throw new RangeError(`controlFactor: no group has a factor: ${thin?.reason ?? \"the rows hold no group to compare.\"}`);\n }\n return { base, factors };\n}\n\n/** This function gives the factors over one base group. Each factor reads the keys that the two groups share. */\nfunction againstGroup(groups: Map<string, Map<string, ControlRow>>, base: string, minPairs: number): ControlFactors {\n const baseRows = groups.get(base);\n if (baseRows === undefined) throw new RangeError(`controlFactor: the base ${JSON.stringify(base)} is not a group of the rows.`);\n const factors: GroupFactor[] = [];\n for (const [group, rows] of groups) {\n if (group === base) continue;\n const ratios: number[] = [];\n let censored = 0;\n let unshared = 0;\n for (const [key, r] of rows) {\n const b = baseRows.get(key);\n if (b === undefined) unshared += 1;\n else if (r.censored === true || b.censored === true) censored += 1;\n else ratios.push(r.value / b.value);\n }\n factors.push(factorOf(group, ratios, censored, unshared, minPairs));\n }\n return withFactors(base, factors);\n}\n\n/**\n * This function gives the factors over the median of each key, as one run grouped by shard needs.\n * Each group holds a different mix of work, so a time compares only with the times of the same key. A key in one group has nothing to compare with.\n */\nfunction againstKeys(groups: Map<string, Map<string, ControlRow>>, minPairs: number): ControlFactors {\n const clean = new Map<string, number[]>();\n for (const rows of groups.values()) {\n for (const [key, r] of rows) if (r.censored !== true) clean.set(key, [...(clean.get(key) ?? []), r.value]);\n }\n const factors = [...groups].map(([group, rows]) => {\n const ratios: number[] = [];\n let censored = 0;\n let unshared = 0;\n for (const [key, r] of rows) {\n const times = clean.get(key) ?? [];\n if (r.censored === true) censored += 1;\n else if (times.length >= 2) ratios.push(r.value / median(times));\n else unshared += 1;\n }\n return factorOf(group, ratios, censored, unshared, minPairs);\n });\n return withFactors(undefined, factors);\n}\n\n/**\n * This function gives the load factor of each group from the times of a control.\n *\n * With `base`, a factor compares the keys that a group shares with that group. Without it, a factor compares each time with the median of its key over the groups.\n * A key names a class of work, so equal keys in two groups mean equal work. Each group has at most one row for a key.\n *\n * A censored time is only a lower limit, so no ratio reads it, and the result counts those keys. A run stops its slowest cases, so a factor reads low when `censored` is not 0.\n *\n * A group with too few usable keys gets an entry with no factor and its reason, so the other groups keep their factors. This function refuses a result where no group has a factor.\n */\nexport function controlFactor(rows: readonly ControlRow[], options: ControlOptions = {}): ControlFactors {\n const minPairs = options.minPairs ?? DEFAULT_MIN_PAIRS;\n if (!(Number.isInteger(minPairs) && minPairs >= 1)) throw new RangeError(`controlFactor: minPairs is a whole number of 1 or more, not ${minPairs}.`);\n const groups = checkedRows(rows);\n return options.base === undefined ? againstKeys(groups, minPairs) : againstGroup(groups, options.base, minPairs);\n}\n","/**\n * The scale ladder of a product, as data. A ladder has rungs at sizes that grow, for example 1, 10 and 100 tenants. Each\n * rung has budgets, and it names the test that holds it. A rung is held only when a record of that test shows each budget\n * `within`. A number in a document is not a rung.\n */\nimport { quantile, quantileInterval, quantileSamples, wilson } from \"@mark1russell7/rigor-statistics\";\nimport { type BudgetOutcome, type BudgetRound, budgetVerdict } from \"./budget.ts\";\n\n/** The format name of a ladder. It changes when a reader of an older form cannot read the data. */\nexport const LADDER_FORMAT = \"rigor-ladder/1\";\n\n/** One dimension of a ladder, for example tenants or nodes. */\nexport interface LadderDimension {\n readonly name: string;\n /** What one unit of the dimension is, in plain words. */\n readonly describe: string;\n}\n\n/** A budget on the median of each case, for example the time of a read. A record gives rounds and an A/A arm. */\nexport interface MedianBudget {\n readonly kind: \"median\";\n readonly measure: string;\n /** The unit of the limit and of the values. */\n readonly unit: string;\n /** The largest median that the budget permits. */\n readonly limit: number;\n /** The largest difference between the medians of the two arms. A larger difference makes the run too noisy. */\n readonly maxDifference: number;\n /** The level of the interval of each median. The default is 0.95. */\n readonly caseLevel?: number;\n}\n\n/** A budget on the share of failed trials, for example failed requests. A record gives failures and trials. */\nexport interface RateBudget {\n readonly kind: \"rate\";\n readonly measure: string;\n /** The largest share of failures that the budget permits, from 0 to 1. */\n readonly limit: number;\n}\n\n/** A budget on the largest value of a set of drills, for example the writes that a restore lost. One bad drill is `beyond`. */\nexport interface WorstBudget {\n readonly kind: \"worst\";\n readonly measure: string;\n readonly unit: string;\n /** The largest value that the budget permits in any drill. */\n readonly limit: number;\n /** The number of drills that a verdict needs, 1 or more. With fewer, the budget is `cannot decide`. */\n readonly minDrills: number;\n}\n\n/**\n * A budget on a high quantile, for example the p99 of a read. A record gives the values. The verdict is the distribution-free\n * interval of the quantile against the limit. A p99 needs 368 independent values at the level 0.95: refer to `quantileSamples`.\n * Successive times of one run can follow each other. Space them apart, or give one value for each run.\n *\n * The evidence can also hold `censored`: a lower bound for each arrival with no reply, and for each arrival that was not\n * sent. The bound is the time that the arrival waited. The true value is that bound or more, with no upper limit. Thus the\n * low end of the interval reads the bounds, and the high end reads each censored value as `Infinity`. A `beyond` stays\n * provable from the bounds alone. A `within` needs real replies up to the upper rank of the interval.\n */\nexport interface QuantileBudget {\n readonly kind: \"quantile\";\n readonly measure: string;\n /** The unit of the limit and of the values. */\n readonly unit: string;\n /** The quantile, more than 0 and less than 1, for example 0.99. */\n readonly quantile: number;\n /** The largest quantile that the budget permits. */\n readonly limit: number;\n /** The level of the interval. The default is 0.95. */\n readonly level?: number;\n}\n\n/** One budget of a rung. */\nexport type RungBudget = MedianBudget | QuantileBudget | RateBudget | WorstBudget;\n\n/** One rung of a ladder. */\nexport interface Rung {\n /** The name of the rung, unique in the ladder. */\n readonly name: string;\n /** The size of the rung in each dimension that it names. */\n readonly at: Readonly<Record<string, number>>;\n readonly budgets: readonly RungBudget[];\n /** The name of the automatic test that holds the rung. */\n readonly test: string;\n /** True when a gate holds the rung: the verdict fails when the rung is not `within`. */\n readonly locked?: boolean;\n}\n\n/** The ladder of one subject. The rungs go from the smallest to the largest. */\nexport interface Ladder {\n readonly format: typeof LADDER_FORMAT;\n /** The product or the service that the ladder is for. */\n readonly subject: string;\n readonly dimensions: readonly LadderDimension[];\n readonly rungs: readonly Rung[];\n}\n\n/** The measured evidence for one budget. Its `kind` is the kind of the budget. */\nexport type RungEvidence =\n | { readonly kind: \"median\"; readonly measure: string; readonly rounds: readonly BudgetRound[]; readonly aa: readonly BudgetRound[] }\n | { readonly kind: \"quantile\"; readonly measure: string; readonly values: readonly number[]; readonly censored?: readonly number[] }\n | { readonly kind: \"rate\"; readonly measure: string; readonly failures: number; readonly trials: number }\n | { readonly kind: \"worst\"; readonly measure: string; readonly values: readonly number[] };\n\n/** One run of the test of a rung. */\nexport interface RungRecord {\n /** The name of the rung. */\n readonly rung: string;\n /** The commit that the run measured. */\n readonly commit: string;\n /** The time of the run, as an ISO 8601 string. */\n readonly at: string;\n /** What the run did for real, for example \"2 processes\" or \"a restore from a real backup\". */\n readonly real: readonly string[];\n /** What the run made up, for example \"90 % of the tenants as data at rest\". An empty list states that nothing was synthetic. */\n readonly synthetic: readonly string[];\n readonly evidence: readonly RungEvidence[];\n}\n\n/** The verdict of one budget of a rung. */\nexport interface BudgetResult {\n readonly measure: string;\n readonly outcome: BudgetOutcome;\n /** The reason of the outcome, in one sentence, with the numbers. */\n readonly reason: string;\n}\n\n/** The verdict of one rung. */\nexport interface RungVerdict {\n readonly rung: string;\n readonly test: string;\n readonly locked: boolean;\n readonly outcome: BudgetOutcome;\n /** The reason of the outcome, in one sentence. */\n readonly reason: string;\n readonly budgets: readonly BudgetResult[];\n /** The commit of the record, or undefined when the rung has no record. */\n readonly commit: string | undefined;\n readonly real: readonly string[];\n readonly synthetic: readonly string[];\n}\n\n/** The verdict of a ladder. */\nexport interface LadderVerdict {\n readonly subject: string;\n /** The highest rung with each rung up to it `within`, or undefined when the first rung is not `within`. */\n readonly held: string | undefined;\n /** The first rung that is not `within`, or undefined when each rung is `within`. */\n readonly next: string | undefined;\n /** True when a locked rung is not `within`. A rung with no result is not held, so `cannot decide` fails too. */\n readonly failed: boolean;\n /** The reason of `failed`, in one sentence. */\n readonly reason: string;\n readonly rungs: readonly RungVerdict[];\n}\n\n/** The options of a ladder verdict. */\nexport interface LadderOptions {\n /** The time of the verdict, as an ISO 8601 string. It is an input, so that a verdict is the same at each read. */\n readonly now: string;\n /** The largest age of a record, in days. An older record gives `cannot decide`. The default accepts any age. */\n readonly maxAgeDays?: number;\n}\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n\n/** This function gives the problems of one budget. */\nfunction budgetProblems(where: string, budget: RungBudget): string[] {\n const out: string[] = [];\n const name = `${where}, budget ${JSON.stringify(budget.measure)}`;\n if (budget.measure.trim() === \"\") out.push(`${where}: a budget has no measure.`);\n if (!(Number.isFinite(budget.limit) && budget.limit >= 0)) out.push(`${name}: the limit is finite and 0 or more, not ${budget.limit}.`);\n if (budget.kind === \"rate\" && budget.limit > 1) out.push(`${name}: a rate limit is at most 1, not ${budget.limit}.`);\n if (budget.kind === \"median\" && !(Number.isFinite(budget.maxDifference) && budget.maxDifference >= 0)) {\n out.push(`${name}: the largest difference is finite and 0 or more, not ${budget.maxDifference}.`);\n }\n if (budget.kind === \"worst\" && !(Number.isInteger(budget.minDrills) && budget.minDrills >= 1)) {\n out.push(`${name}: the number of drills is a whole number of 1 or more, not ${budget.minDrills}.`);\n }\n if (budget.kind === \"quantile\" && !(budget.quantile > 0 && budget.quantile < 1)) out.push(`${name}: a quantile is more than 0 and less than 1, not ${budget.quantile}.`);\n if (budget.kind === \"quantile\" && budget.level !== undefined && !(budget.level > 0 && budget.level < 1)) out.push(`${name}: a level is more than 0 and less than 1, not ${budget.level}.`);\n return out;\n}\n\n/** This function gives the problems of one rung, in the order of its fields. */\nfunction rungProblems(rung: Rung, dimensions: ReadonlySet<string>): string[] {\n const where = `The rung ${JSON.stringify(rung.name)}`;\n const out: string[] = [];\n const names = Object.keys(rung.at);\n if (names.length === 0) out.push(`${where} names no dimension.`);\n for (const name of names) {\n if (!dimensions.has(name)) out.push(`${where} names the unknown dimension ${JSON.stringify(name)}.`);\n const size = rung.at[name];\n if (!(typeof size === \"number\" && Number.isFinite(size) && size > 0)) out.push(`${where}: the size of ${JSON.stringify(name)} is finite and above 0, not ${size}.`);\n }\n if (rung.test.trim() === \"\") out.push(`${where} names no test.`);\n if (rung.budgets.length === 0) out.push(`${where} has no budgets.`);\n const measures = new Set<string>();\n for (const budget of rung.budgets) {\n if (measures.has(budget.measure)) out.push(`${where} has two budgets of ${JSON.stringify(budget.measure)}.`);\n measures.add(budget.measure);\n out.push(...budgetProblems(where, budget));\n }\n return out;\n}\n\n/**\n * This function gives each problem of a ladder as data, or an empty list. A ladder needs a subject, one dimension or more,\n * and one rung or more. Names are unique. Each rung names a test and has budgets. From one rung to the next, each dimension\n * that the two rungs name grows.\n */\nexport function checkLadder(ladder: Ladder): readonly string[] {\n const out: string[] = [];\n if (ladder.format !== LADDER_FORMAT) out.push(`The format is ${JSON.stringify(LADDER_FORMAT)}, not ${JSON.stringify(ladder.format)}.`);\n if (ladder.subject.trim() === \"\") out.push(\"The ladder has no subject.\");\n if (ladder.dimensions.length === 0) out.push(\"The ladder has no dimensions.\");\n if (ladder.rungs.length === 0) out.push(\"The ladder has no rungs.\");\n const dimensions = new Set(ladder.dimensions.map((d) => d.name));\n if (dimensions.size !== ladder.dimensions.length) out.push(\"Two dimensions have the same name.\");\n if (new Set(ladder.rungs.map((r) => r.name)).size !== ladder.rungs.length) out.push(\"Two rungs have the same name.\");\n ladder.rungs.forEach((rung, index) => {\n out.push(...rungProblems(rung, dimensions));\n const before = ladder.rungs[index - 1];\n if (before === undefined) return;\n for (const [name, size] of Object.entries(rung.at)) {\n const low = before.at[name];\n if (low !== undefined && !(size > low)) out.push(`The rung ${JSON.stringify(rung.name)}: ${JSON.stringify(name)} does not grow from ${low} to ${size}.`);\n }\n });\n return out;\n}\n\n/** This function gives the verdict of a rate: the Wilson interval at 95 % against the limit. */\nfunction rateResult(budget: RateBudget, failures: number, trials: number): BudgetResult {\n const interval = wilson(failures, trials);\n const facts = `${failures} failures of ${trials} trials, interval ${interval.low} to ${interval.high}, limit ${budget.limit}`;\n const outcome: BudgetOutcome = trials === 0 ? \"cannot decide\" : interval.high <= budget.limit ? \"within\" : interval.low > budget.limit ? \"beyond\" : \"cannot decide\";\n return { measure: budget.measure, outcome, reason: `The measure ${JSON.stringify(budget.measure)} is \"${outcome}\" (${facts}).` };\n}\n\n/** This function gives the verdict of a set of drills: the largest value against the limit. */\nfunction worstResult(budget: WorstBudget, values: readonly number[]): BudgetResult {\n const largest = values.length === 0 ? undefined : Math.max(...values);\n const facts = `${values.length} drills, the largest ${largest ?? \"none\"} ${budget.unit}, limit ${budget.limit}`;\n const outcome: BudgetOutcome = largest !== undefined && largest > budget.limit ? \"beyond\" : values.length < budget.minDrills ? \"cannot decide\" : \"within\";\n return { measure: budget.measure, outcome, reason: `The measure ${JSON.stringify(budget.measure)} is \"${outcome}\" (${facts}, ${budget.minDrills} drills needed).` };\n}\n\n/**\n * This function gives the verdict of a quantile: its distribution-free interval against the limit. With censored values, the\n * low end reads their bounds and the high end reads them as `Infinity`. Each true sample has its interval inside that one.\n */\nfunction quantileResult(budget: QuantileBudget, values: readonly number[], censored: readonly number[]): BudgetResult {\n const level = budget.level ?? 0.95;\n const needed = quantileSamples(budget.quantile, level);\n const say = (outcome: BudgetOutcome, facts: string): BudgetResult => ({ measure: budget.measure, outcome, reason: `The measure ${JSON.stringify(budget.measure)} is \"${outcome}\" (${facts}, ${needed} values needed).` });\n const open = censored.length > 0;\n const bounds = [...values, ...censored];\n if (bounds.length === 0) return say(\"cannot decide\", `0 values, limit ${budget.limit} ${budget.unit}`);\n if (values.some((value) => Number.isNaN(value))) return say(\"cannot decide\", \"the values have a NaN\");\n if (!censored.every((value) => Number.isFinite(value))) return say(\"cannot decide\", \"a censored value is not a finite number\");\n const lowest = quantileInterval(bounds, budget.quantile, level);\n const highest = open ? quantileInterval([...values, ...censored.map(() => Infinity)], budget.quantile, level) : lowest;\n const [count, point] = open ? [`${values.length} values and ${censored.length} censored`, \"at least\"] : [`${values.length} values`, \"at\"];\n const facts = `${count}, quantile ${budget.quantile} ${point} ${quantile(bounds, budget.quantile, \"nearest-rank\")} ${budget.unit}, interval ${lowest.low} to ${highest.high}, limit ${budget.limit}`;\n return say(highest.high <= budget.limit ? \"within\" : lowest.low > budget.limit ? \"beyond\" : \"cannot decide\", facts);\n}\n\n/** This function gives the verdict of one budget from the evidence of a record. */\nfunction budgetResult(budget: RungBudget, evidence: readonly RungEvidence[]): BudgetResult {\n const found = evidence.find((e) => e.measure === budget.measure);\n const none = (why: string): BudgetResult => ({ measure: budget.measure, outcome: \"cannot decide\", reason: `The measure ${JSON.stringify(budget.measure)} is \"cannot decide\": ${why}.` });\n if (found === undefined) return none(\"the record has no evidence for it\");\n if (budget.kind === \"median\" && found.kind === \"median\") {\n const v = budgetVerdict(found.rounds, found.aa, { limit: budget.limit, maxDifference: budget.maxDifference, ...(budget.caseLevel === undefined ? {} : { caseLevel: budget.caseLevel }) });\n return { measure: budget.measure, outcome: v.outcome, reason: v.reason };\n }\n if (budget.kind === \"quantile\" && found.kind === \"quantile\") return quantileResult(budget, found.values, found.censored ?? []);\n if (budget.kind === \"rate\" && found.kind === \"rate\") return rateResult(budget, found.failures, found.trials);\n if (budget.kind === \"worst\" && found.kind === \"worst\") return worstResult(budget, found.values);\n return none(`the budget is ${budget.kind}, and the evidence is ${found.kind}`);\n}\n\n/** This function gives the reason that a record cannot decide a rung, or undefined when the record can. */\nfunction recordProblem(record: RungRecord, options: LadderOptions): string | undefined {\n if (record.real.length === 0) return \"the record does not state what was real\";\n const { maxAgeDays } = options;\n if (maxAgeDays === undefined) return undefined;\n const age = (Date.parse(options.now) - Date.parse(record.at)) / DAY_MS;\n if (!Number.isFinite(age)) return `a time does not parse: now ${options.now}, record ${record.at}`;\n return age > maxAgeDays ? `the record of ${record.at} is older than ${maxAgeDays} days` : undefined;\n}\n\n/** This function gives the outcome of a set of budgets: `beyond` first, then `cannot decide`, and `within` only when each budget is. */\nfunction worstOutcome(results: readonly BudgetResult[]): BudgetOutcome {\n if (results.some((r) => r.outcome === \"beyond\")) return \"beyond\";\n return results.length > 0 && results.every((r) => r.outcome === \"within\") ? \"within\" : \"cannot decide\";\n}\n\n/** This function gives the verdict of one rung from its record. With no record, the rung is `cannot decide`. */\nexport function rungVerdict(rung: Rung, record: RungRecord | undefined, options: LadderOptions): RungVerdict {\n const base = { rung: rung.name, test: rung.test, locked: rung.locked === true };\n if (record === undefined) {\n return { ...base, outcome: \"cannot decide\", reason: `The rung ${JSON.stringify(rung.name)} has no record of the test ${JSON.stringify(rung.test)}.`, budgets: [], commit: undefined, real: [], synthetic: [] };\n }\n const facts = { commit: record.commit, real: record.real, synthetic: record.synthetic };\n const problem = recordProblem(record, options);\n if (problem !== undefined) return { ...base, ...facts, outcome: \"cannot decide\", reason: `The rung ${JSON.stringify(rung.name)} is \"cannot decide\": ${problem}.`, budgets: [] };\n const budgets = rung.budgets.map((b) => budgetResult(b, record.evidence));\n const outcome = worstOutcome(budgets);\n const first = budgets.find((b) => b.outcome === outcome);\n return { ...base, ...facts, outcome, reason: outcome === \"within\" ? `The ${budgets.length} budgets of the rung ${JSON.stringify(rung.name)} are within.` : `The rung ${JSON.stringify(rung.name)} is \"${outcome}\". ${first?.reason ?? \"\"}`, budgets };\n}\n\n/** This function gives the newest record of each rung. It keeps the first of two records with the same time. */\nfunction newestRecords(records: readonly RungRecord[]): Map<string, RungRecord> {\n const out = new Map<string, RungRecord>();\n for (const record of records) {\n const old = out.get(record.rung);\n if (old === undefined || Date.parse(record.at) > Date.parse(old.at)) out.set(record.rung, record);\n }\n return out;\n}\n\n/**\n * This function gives the verdict of a ladder from the records of its rungs. It uses the newest record of each rung, so an\n * older pass does not hide a newer failure. A rung high up does not count when a rung below it is not `within`. It throws\n * a `RangeError` for a ladder with problems, because a verdict on a bad ladder has no meaning. See `checkLadder`.\n */\nexport function ladderVerdict(ladder: Ladder, records: readonly RungRecord[], options: LadderOptions): LadderVerdict {\n const problems = checkLadder(ladder);\n if (problems.length > 0) throw new RangeError(`ladderVerdict: ${problems.join(\" \")}`);\n const newest = newestRecords(records);\n const rungs = ladder.rungs.map((r) => rungVerdict(r, newest.get(r.name), options));\n const firstOpen = rungs.findIndex((r) => r.outcome !== \"within\");\n const heldCount = firstOpen === -1 ? rungs.length : firstOpen;\n const lost = rungs.filter((r) => r.locked && r.outcome !== \"within\");\n const reason = lost.length === 0 ? `Each of the ${rungs.filter((r) => r.locked).length} locked rungs is within.` : `${lost.length} locked rungs are not within. ${lost[0]?.reason ?? \"\"}`;\n return { subject: ladder.subject, held: rungs[heldCount - 1]?.rung, next: rungs[heldCount]?.rung, failed: lost.length > 0, reason, rungs };\n}\n","/**\n * The time verdict of a candidate against a baseline, with the noise of an A/A arm. An A/A pair runs the same code in\n * its two arms. Its ratios show how far apart two equal arms come on this machine. A candidate is faster or slower only\n * when its interval is out of that band.\n */\nimport { type BootstrapOptions, type Comparison, type Interval, bootstrapMedian, bootstrapTwo, compareRatios, median, quantile } from \"@mark1russell7/rigor-statistics\";\nimport { type CaseRatio, type PairedTime, caseRatios } from \"./paired.ts\";\n\n/**\n * The two kinds of an A/A band.\n * - The band `case` holds the ratio of one A/A case. It is wide, so it finds only a large change.\n * - The band `median` holds the median ratio of the A/A cases. It has the scale of the median of the candidate.\n */\nexport type BandKind = \"case\" | \"median\";\n\n/** The options of the A/A band. */\nexport interface BandOptions {\n /** The kind of the band. The default is `median`, from the power test of `verdictPower`. */\n readonly kind?: BandKind;\n /** The quantile of the band `case`, or the level of the bootstrap of the band `median`. The default is 0.95. */\n readonly level?: number;\n /** The fewest A/A cases that give a band. The default is 5, the 5-seed rule. */\n readonly minimum?: number;\n /** The bootstrap of the band `median`. The level of the band replaces its level. */\n readonly bootstrap?: BootstrapOptions;\n}\n\n/** The band of the A/A arm: two equal arms come out in this band of ratios. */\nexport interface Band {\n /** The count of the A/A cases. */\n readonly cases: number;\n readonly kind: BandKind;\n /**\n * The half width of the band on a log scale.\n * For the band `case`, it is the `level` quantile of `abs(log(ratio))` over the A/A cases.\n * For the band `median`, it is the larger distance of an end of the bootstrap interval of the A/A median from 0.\n */\n readonly noise: number;\n /** The ends of the band: `exp(-noise)` and `exp(noise)`. */\n readonly low: number;\n readonly high: number;\n /** The median ratio of the A/A cases. A value far from 1 shows a bias of the order or of the arm slots. */\n readonly median: number;\n}\n\n/** This function gives the band of the A/A arm. The band is symmetric on a log scale. It refuses fewer cases than `minimum`. */\nexport function aaBand(aa: readonly PairedTime[], options: BandOptions = {}): Band {\n const ratios = caseRatios(aa);\n const minimum = options.minimum ?? 5;\n if (ratios.length < minimum) throw new RangeError(`aaBand: the A/A arm has ${ratios.length} cases, and a band needs ${minimum} or more.`);\n const logs = ratios.map((r) => Math.log(r.ratio));\n const kind = options.kind ?? \"median\";\n const level = options.level ?? 0.95;\n let noise: number;\n if (kind === \"case\") noise = quantile(logs.map(Math.abs), level);\n else {\n const interval = bootstrapMedian(logs, { ...options.bootstrap, level });\n noise = Math.max(Math.abs(interval.low), Math.abs(interval.high));\n }\n return { cases: ratios.length, kind, noise, low: Math.exp(-noise), high: Math.exp(noise), median: Math.exp(quantile(logs, 0.5)) };\n}\n\n/**\n * This function gives the A/A spread: the `level` quantile of `abs(log(ratio))` over the A/A cases. The default level is 0.9.\n * It refuses an A/A arm with no cases.\n */\nexport function aaSpread(aa: readonly PairedTime[], level = 0.9): number {\n const ratios = caseRatios(aa);\n if (ratios.length === 0) throw new RangeError(\"aaSpread: the A/A arm has no cases.\");\n return spreadOf(ratios, level);\n}\n\nfunction spreadOf(ratios: readonly CaseRatio[], level: number): number {\n return quantile(ratios.map((r) => Math.abs(Math.log(r.ratio))), level);\n}\n\n/** The options of a pooled band: the A/A records of earlier quiet runs, and a floor. The caller keeps the pool. */\nexport interface PoolOptions {\n /** The A/A records of the earlier runs. Give each run its own case names, for example with the run id as a prefix. */\n readonly records: readonly PairedTime[];\n /** The smallest noise of the band, on a log scale. The default is 0. A floor of `Math.log(1.05)` gives at least the band `[1 / 1.05, 1.05]`. */\n readonly floor?: number;\n /** The fewest pooled cases that give a spread. With fewer cases, the noise of the band is the floor. The default is 5. */\n readonly minimum?: number;\n /**\n * The run of a record, for example the id of its CI run. The verdict counts the runs of the pool with it.\n * The cases of one run share one runner, so they are not independent. Many cases from few runs show the noise of few runners.\n */\n readonly run?: (record: PairedTime) => string;\n}\n\n/** The facts of the pooled band of a verdict. */\nexport interface PoolFacts {\n /** The count of the pooled A/A cases. */\n readonly cases: number;\n /** The count of the runs of the pool, from the option `run`. It is undefined without that option. */\n readonly runs: number | undefined;\n /** The A/A spread of the pooled cases, or undefined when the pool has fewer cases than `minimum`. */\n readonly spread: number | undefined;\n readonly floor: number;\n /** This value is `true` when the spread of the pool is larger than the floor, so the spread gives the noise of the band. */\n readonly pooled: boolean;\n}\n\n/**\n * This function gives the pooled band of the kind `case`. Its noise is the larger of the floor and the A/A spread of the pooled records.\n * The spread is the `level` quantile of `abs(log(ratio))`, with the default level 0.9.\n *\n * A band with fewer pooled cases than `minimum` uses the floor alone. A band with no pooled cases has the median 1.\n */\nexport function pooledBand(pool: PoolOptions, level = 0.9): Band {\n return poolOf(pool, level).band;\n}\n\nfunction poolOf(pool: PoolOptions, level: number): { band: Band; facts: PoolFacts } {\n const floor = pool.floor ?? 0;\n const minimum = pool.minimum ?? 5;\n if (!(floor >= 0 && Number.isFinite(floor))) throw new RangeError(`pooledBand: the floor is a finite number of 0 or more, not ${floor}.`);\n if (!Number.isSafeInteger(minimum) || minimum < 1) throw new RangeError(`pooledBand: the minimum is a whole number of 1 or more, not ${minimum}.`);\n const ratios = caseRatios(pool.records);\n const spread = ratios.length >= minimum ? spreadOf(ratios, level) : undefined;\n const noise = Math.max(floor, spread ?? 0);\n const median = ratios.length === 0 ? 1 : Math.exp(quantile(ratios.map((r) => Math.log(r.ratio)), 0.5));\n const band: Band = { cases: ratios.length, kind: \"case\", noise, low: Math.exp(-noise), high: Math.exp(noise), median };\n const runs = pool.run === undefined ? undefined : new Set(pool.records.map(pool.run)).size;\n return { band, facts: { cases: ratios.length, runs, spread, floor, pooled: spread !== undefined && spread > floor } };\n}\n\n/** The four outcomes of a time verdict. The candidate is the arm `b`, so `faster` is a ratio below 1. */\nexport type TimeOutcome = \"faster\" | \"slower\" | \"same\" | \"cannot decide\";\n\n/** The options of a time verdict. The bootstrap gives the interval of the median ratio of the candidate, and the band `median`. */\n/**\n * The two rules of a time verdict.\n * - The rule `band` compares the interval of the median ratio of the candidate with the A/A band.\n * - The rule `difference` compares the interval of the candidate median over the A/A median with 1 and with `margin`.\n */\nexport type VerdictRule = \"band\" | \"difference\";\n\n/** The options of a time verdict. The bootstrap gives each interval of the verdict. */\nexport interface VerdictOptions extends BandOptions {\n /** The rule of the verdict. The default is `difference`, from the power test of `verdictPower`. */\n readonly rule?: VerdictRule;\n /**\n * The half width on a log scale of the ratios that the rule `difference` calls `same`. The default is 0.05.\n * An interval in the margin is `same`, also when it is wholly below 1.\n */\n readonly margin?: number;\n /**\n * The noise cap on the A/A spread of the run, on a log scale. Above the cap, the outcome is `cannot decide`.\n * The cap also limits the bias of the A/A arm: an A/A median ratio out of `[exp(-noiseCap), exp(noiseCap)]` gives `cannot decide`.\n * The default is no cap.\n */\n readonly noiseCap?: number;\n /** The quantile of the A/A spread of the noise cap and of the pooled band. The default is 0.9. */\n readonly spreadLevel?: number;\n /**\n * The pooled band. It replaces the band of the A/A arm of the run in the rule `band` and in `comparison`.\n * The rule `difference` uses the larger of `margin` and the noise of the pooled band as its margin. The default is no pool.\n */\n readonly pool?: PoolOptions;\n}\n\n/** The noise cap of a verdict: the A/A spread of the run, the A/A median ratio of the run and the cap. */\nexport interface NoiseCheck {\n /** The A/A spread of the run, or undefined when the A/A arm has no cases. */\n readonly spread: number | undefined;\n readonly cap: number;\n /** This value is `true` when the spread is above the cap, or when the A/A arm has no cases. */\n readonly noisy: boolean;\n /** The median ratio of the A/A cases of the run, or undefined when the A/A arm has no cases. A value far from 1 shows a bias of the order or of the arm slots. */\n readonly aaMedian: number | undefined;\n /**\n * This value is `true` when the A/A median ratio of the run is out of `[exp(-cap), exp(cap)]`.\n * With a spread level of 0.5 or more, a biased run is also noisy. The check decides alone only below that level.\n */\n readonly biased: boolean;\n}\n\n/** A time verdict, with the facts that it uses. */\nexport interface TimeVerdict {\n readonly outcome: TimeOutcome;\n /** The reason of the outcome, in one sentence. */\n readonly reason: string;\n readonly cases: readonly CaseRatio[];\n readonly rule: VerdictRule;\n /**\n * The interval that the rule compares, or undefined when there are no candidate cases.\n * With too few A/A cases, it is the interval of the median ratio of the candidate.\n * For the rule `band`, it is the bootstrap interval of the median ratio of the candidate.\n * For the rule `difference`, it is the interval of the candidate median ratio over the A/A median ratio.\n */\n readonly interval: Interval | undefined;\n /** The band of the A/A arm, or undefined when the A/A arm has too few cases. */\n readonly band: Band | undefined;\n /**\n * The counts of the cases out of the band, or undefined without a band.\n * The comparison uses the value `1 + log(ratio)` of each case and the noise of the band, so its two sides are the ends of the band.\n */\n readonly comparison: Comparison | undefined;\n /** The facts of the pooled band. The verdict has this field only with the option `pool`. */\n readonly pool?: PoolFacts;\n /** The noise cap. The verdict has this field only with the option `noiseCap`. */\n readonly noise?: NoiseCheck;\n}\n\n/**\n * This function gives the time verdict of the candidate arm `b` against the baseline arm `a`.\n * - The rule `difference` gives `same` when the interval is in `[exp(-margin), exp(margin)]`. This test comes first, so\n * an interval in the margin and below 1 is `same`, not `faster`.\n * - Out of the margin, the rule `difference` gives `faster` when the whole interval is below 1, and `slower` when it is above 1.\n * With the margin 0, each outcome stays the same as in 0.1.2.\n * - The rule `band` gives `faster` below the band, `slower` above the band, and `same` in the band.\n * - Each other case is `cannot decide`, and so is an A/A arm with too few cases.\n * - With `noiseCap`, an A/A spread of the run above the cap gives `cannot decide`.\n * - With `noiseCap`, an A/A median ratio of the run out of `[exp(-noiseCap), exp(noiseCap)]` also gives `cannot decide`.\n * - With `pool`, the pooled band replaces the band of the A/A arm of the run. The run still needs `minimum` A/A cases.\n */\nexport function timeVerdict(candidate: readonly PairedTime[], aa: readonly PairedTime[], options: VerdictOptions = {}): TimeVerdict {\n const level = options.spreadLevel ?? 0.9;\n if (options.noiseCap !== undefined && !(options.noiseCap >= 0 && Number.isFinite(options.noiseCap))) {\n throw new RangeError(`timeVerdict: the noise cap is a finite number of 0 or more, not ${options.noiseCap}.`);\n }\n const pool = poolFor(options);\n let verdict = ruleVerdict(candidate, aa, options, pool?.band);\n if (pool !== undefined) verdict = { ...verdict, pool: pool.facts };\n if (options.noiseCap !== undefined) {\n const cap = options.noiseCap;\n const aaRatios = caseRatios(aa);\n const spread = aaRatios.length === 0 ? undefined : spreadOf(aaRatios, level);\n const aaMedian = aaRatios.length === 0 ? undefined : Math.exp(quantile(aaRatios.map((r) => Math.log(r.ratio)), 0.5));\n const biased = aaMedian !== undefined && Math.abs(Math.log(aaMedian)) > cap;\n const noise: NoiseCheck = { spread, cap, noisy: spread === undefined || spread > cap, aaMedian, biased };\n verdict = { ...verdict, noise };\n // The early outcomes (no candidate cases, too few A/A cases) keep their reason. Each other outcome gives way to the cap.\n if (noise.noisy && verdict.band !== undefined) {\n const why = spread === undefined ? \"The A/A arm of the run has no cases, so the noise cap has no spread.\" : `The A/A spread of the run is ${round(spread)}, above the noise cap ${cap}.`;\n const reason = `${why} Without the cap, the outcome is \"${verdict.outcome}\".`;\n verdict = { ...verdict, outcome: \"cannot decide\", reason };\n } else if (noise.biased && verdict.band !== undefined) {\n const reason = `The A/A median ratio of the run is ${round(aaMedian!)}, out of [${round(Math.exp(-cap))}, ${round(Math.exp(cap))}] of the noise cap ${cap}. Without the cap, the outcome is \"${verdict.outcome}\".`;\n verdict = { ...verdict, outcome: \"cannot decide\", reason };\n }\n }\n return verdict;\n}\n\n/** This function gives the pooled band and its facts of the options, or undefined without the option `pool`. */\nfunction poolFor(options: VerdictOptions): { band: Band; facts: PoolFacts } | undefined {\n return options.pool === undefined ? undefined : poolOf(options.pool, options.spreadLevel ?? 0.9);\n}\n\n/** This function gives the margin of the rule `difference`: the larger of `margin` and the noise of the pooled band. It refuses a margin below 0. */\nfunction marginOf(options: VerdictOptions, pooled: Band | undefined): number {\n const given = options.margin ?? 0.05;\n if (!(given >= 0)) throw new RangeError(`timeVerdict: the margin is 0 or more, not ${given}.`);\n return pooled === undefined ? given : Math.max(given, pooled.noise);\n}\n\n/**\n * This function gives the margin that the rule `difference` of `timeVerdict` uses with these options, on a log scale.\n * The margin is the larger of the option `margin` (default 0.05) and the noise of the pooled band. It uses the same code as the verdict.\n * The pooled band comes from the records of the option `pool`, not from the records of the run.\n * An interval in `[exp(-margin), exp(margin)]` has the outcome `same`. A page can draw that zone with this function.\n */\nexport function verdictMargin(options: VerdictOptions = {}): number {\n return marginOf(options, poolFor(options)?.band);\n}\n\n/** This function gives the outcome of the rule. A pooled band replaces the band of the A/A arm, and it widens the margin of the rule `difference`. */\nfunction ruleVerdict(candidate: readonly PairedTime[], aa: readonly PairedTime[], options: VerdictOptions, pooled: Band | undefined): TimeVerdict {\n const rule = options.rule ?? \"difference\";\n const cases = caseRatios(candidate);\n const aaRatios = caseRatios(aa);\n const minimum = options.minimum ?? 5;\n const none = { cases, rule, interval: undefined, band: undefined, comparison: undefined };\n if (cases.length === 0) return { ...none, outcome: \"cannot decide\", reason: \"The candidate has no cases.\" };\n if (aaRatios.length < minimum) {\n const interval = bootstrapMedian(cases.map((c) => c.ratio), options.bootstrap);\n return { ...none, interval, outcome: \"cannot decide\", reason: `The A/A arm has ${aaRatios.length} cases, and a band needs ${minimum} or more.` };\n }\n const band = pooled ?? aaBand(aa, options);\n const comparison = compareRatios(cases.map((c) => 1 + Math.log(c.ratio)), { better: \"lower\", noise: band.noise });\n const facts = { cases, rule, band, comparison };\n if (rule === \"difference\") {\n const margin = marginOf(options, pooled);\n const shown = pooled === undefined ? margin : round(margin);\n const logs = cases.map((c) => Math.log(c.ratio));\n const aaLogs = aaRatios.map((c) => Math.log(c.ratio));\n const d = bootstrapTwo(logs, aaLogs, (x, y) => median(x) - median(y), options.bootstrap);\n const interval: Interval = { ...d, estimate: Math.exp(d.estimate), low: Math.exp(d.low), high: Math.exp(d.high) };\n const span = `The interval of the candidate median over the A/A median is [${round(interval.low)}, ${round(interval.high)}].`;\n // The margin comes first: an interval in the margin is `same`, also when it is wholly below or above 1.\n if (d.low >= -margin && d.high <= margin) return { ...facts, interval, outcome: \"same\", reason: `${span} The interval is in the margin of ${shown}.` };\n if (interval.high < 1) return { ...facts, interval, outcome: \"faster\", reason: `${span} The interval is below 1.` };\n if (interval.low > 1) return { ...facts, interval, outcome: \"slower\", reason: `${span} The interval is above 1.` };\n return { ...facts, interval, outcome: \"cannot decide\", reason: `${span} The interval holds 1 and crosses the margin of ${shown}.` };\n }\n const interval = bootstrapMedian(cases.map((c) => c.ratio), options.bootstrap);\n const span = `The interval of the median ratio is [${round(interval.low)}, ${round(interval.high)}], and the A/A band is [${round(band.low)}, ${round(band.high)}].`;\n if (interval.high < band.low) return { ...facts, interval, outcome: \"faster\", reason: `${span} The interval is below the band.` };\n if (interval.low > band.high) return { ...facts, interval, outcome: \"slower\", reason: `${span} The interval is above the band.` };\n if (interval.low >= band.low && interval.high <= band.high) return { ...facts, interval, outcome: \"same\", reason: `${span} The interval is in the band.` };\n return { ...facts, interval, outcome: \"cannot decide\", reason: `${span} The interval crosses an end of the band.` };\n}\n\nfunction round(x: number): number {\n return Math.round(x * 10_000) / 10_000;\n}\n","/**\n * The limit verdict of a bench: is the ratio of each case at most a limit? For example, the claim \"the new code takes at most\n * 2 times the time of the old code\" needs it. The time verdict compares only with 1.\n */\nimport { medianInterval } from \"@mark1russell7/rigor-statistics\";\nimport { type CaseRatio, type PairedTime, caseRatios } from \"./paired.ts\";\nimport { type Band, type BandOptions, aaBand } from \"./verdict.ts\";\n\n/** The ratio of one case with the interval of its median over the rounds. */\nexport interface CaseInterval extends CaseRatio {\n /** The ends of the interval: `exp` of `medianInterval` over the values `log(b / a)` of the rounds. */\n readonly low: number;\n readonly high: number;\n /** The coverage of the interval. It is at least the level. */\n readonly coverage: number;\n}\n\n/**\n * This function gives the ratio of each case with a distribution-free interval of its median, in the order of\n * `caseRatios`. It needs enough rounds for the level: 6 rounds or more for the level 0.95.\n */\nexport function caseIntervals(records: readonly PairedTime[], level = 0.95): CaseInterval[] {\n const logs = new Map<string, number[]>();\n for (const r of records) {\n const list = logs.get(r.case) ?? [];\n list.push(Math.log(r.b / r.a));\n logs.set(r.case, list);\n }\n return caseRatios(records).map((c) => {\n const interval = medianInterval(logs.get(c.case)!, level);\n return { ...c, low: Math.exp(interval.low), high: Math.exp(interval.high), coverage: interval.coverage };\n });\n}\n\n/** The three outcomes of a limit verdict. */\nexport type LimitOutcome = \"within\" | \"beyond\" | \"cannot decide\";\n\n/** The options of a limit verdict. */\nexport interface LimitOptions extends BandOptions {\n /** The largest ratio `b / a` that the claim permits, for example 2. */\n readonly limit: number;\n /** The level of the interval of each case. The default is 0.95. */\n readonly caseLevel?: number;\n /**\n * The share of the cases that the claim needs `within`, above 0 and at most 1. The default 1 needs each case. With 0.95\n * and 20 cases, 1 case can be `beyond` or `cannot decide`. The option `timeTailQ` of a promotion record is this share.\n */\n readonly share?: number;\n}\n\n/** The verdict of one case against the limit. */\nexport interface CaseLimit extends CaseInterval {\n /** The high end of the interval of the case, times the high end of the A/A band. */\n readonly bound: number;\n /** The low end of the interval of the case, times the low end of the A/A band. */\n readonly floor: number;\n readonly outcome: LimitOutcome;\n}\n\n/** A limit verdict, with the facts that it uses. */\nexport interface LimitVerdict {\n readonly outcome: LimitOutcome;\n /** The reason of the outcome, in one sentence. */\n readonly reason: string;\n readonly limit: number;\n readonly cases: readonly CaseLimit[];\n /** The band of the A/A arm, or undefined when the A/A arm has too few cases. */\n readonly band: Band | undefined;\n /** The share of the option `share`. */\n readonly share: number;\n /** The number of cases that can be other than `within`: the floor of the number of cases times `1 - share`. */\n readonly allowed: number;\n}\n\n/**\n * This function gives the verdict of the claim \"the ratio `b / a` of each case is at most `limit`\". The A/A band widens\n * the interval of each case: the bound is the high end times the high end of the band.\n * - A case is `within` when its bound is at most the limit, and `beyond` when its floor is above the limit.\n * - The verdict is `within` when `allowed` cases or fewer are other than `within`. With the default share 1, `allowed` is 0.\n * - The verdict is `beyond` when more than `allowed` cases are `beyond`.\n * - Each other verdict is `cannot decide`, and so is an A/A arm with too few cases or a candidate with no cases.\n */\nexport function limitVerdict(candidate: readonly PairedTime[], aa: readonly PairedTime[], options: LimitOptions): LimitVerdict {\n const { limit } = options;\n if (!(limit > 0 && Number.isFinite(limit))) throw new RangeError(`limitVerdict: the limit is a finite number above 0, not ${limit}.`);\n const share = options.share ?? 1;\n if (!(share > 0 && share <= 1)) throw new RangeError(`limitVerdict: the share is above 0 and at most 1, not ${share}.`);\n const intervals = caseIntervals(candidate, options.caseLevel);\n const minimum = options.minimum ?? 5;\n // The small term keeps a product such as 10 * (1 - 0.9) = 0.9999999999999998 from a floor of 0.\n const allowed = Math.floor(intervals.length * (1 - share) + 1e-9);\n if (intervals.length === 0) return { outcome: \"cannot decide\", reason: \"The candidate has no cases.\", limit, cases: [], band: undefined, share, allowed };\n const aaCount = caseRatios(aa).length;\n if (aaCount < minimum) {\n const cases = intervals.map((c) => ({ ...c, bound: c.high, floor: c.low, outcome: \"cannot decide\" as const }));\n return { outcome: \"cannot decide\", reason: `The A/A arm has ${aaCount} cases, and a band needs ${minimum} or more.`, limit, cases, band: undefined, share, allowed };\n }\n const band = aaBand(aa, options);\n const cases = intervals.map((c): CaseLimit => {\n const bound = c.high * band.high;\n const floor = c.low * band.low;\n const outcome: LimitOutcome = bound <= limit ? \"within\" : floor > limit ? \"beyond\" : \"cannot decide\";\n return { ...c, bound, floor, outcome };\n });\n const facts = { limit, cases, band, share, allowed };\n const beyond = cases.filter((c) => c.outcome === \"beyond\");\n const others = cases.filter((c) => c.outcome !== \"within\");\n const permit = allowed === 0 ? \"\" : `, and the share ${share} permits ${allowed}`;\n if (beyond.length > allowed) {\n return { outcome: \"beyond\", reason: `${beyond.length} of ${cases.length} cases are above the limit ${limit}${permit}. The first is ${JSON.stringify(beyond[0]!.case)}.`, ...facts };\n }\n if (others.length <= allowed) {\n const inside = cases.filter((c) => c.outcome === \"within\");\n const top = (inside.length > 0 ? inside : cases).reduce((a, b) => (b.bound > a.bound ? b : a));\n const rest = others.length === 0 ? \"\" : ` ${others.length} of ${cases.length} cases are not within${permit}.`;\n return { outcome: \"within\", reason: `The largest bound of a case within is ${round(top.bound)} in the case ${JSON.stringify(top.case)}, and it is at most the limit ${limit}.${rest}`, ...facts };\n }\n const top = cases.reduce((a, b) => (b.bound > a.bound ? b : a));\n return { outcome: \"cannot decide\", reason: `${others.length} of ${cases.length} cases are not within${permit}. The bound of the case ${JSON.stringify(top.case)} is ${round(top.bound)}, above the limit ${limit}, and too few floors are above it.`, ...facts };\n}\n\nfunction round(x: number): number {\n return Math.round(x * 10_000) / 10_000;\n}\n","/**\n * The merge of the records of many jobs, and the pooled verdicts over them. Each job of a bench gives its own records.\n * A pooled verdict uses all jobs together, and the verdict of each job alone guards it.\n */\nimport { type LimitOptions, type LimitOutcome, type LimitVerdict, limitVerdict } from \"./limit.ts\";\nimport { type Arm, type PairedTime } from \"./paired.ts\";\nimport { type TimeOutcome, type TimeVerdict, type VerdictOptions, timeVerdict } from \"./verdict.ts\";\n\n/** The records of each case with a turned order, and the count of the records that the balance removed. */\nexport interface Balanced<T extends PairedTime> {\n readonly records: T[];\n /** The count of the removed records. It is 0 when each case has a turned order. */\n readonly trimmed: number;\n}\n\n/**\n * This function removes records until the two orders of each case differ in count by 1 or less.\n * It removes the records of the larger order with the highest rounds first. The other records keep their order.\n * A job that stopped early, or a missing job, can leave a case with 2 more rounds of one order. `caseRatios` refuses such a case.\n */\nexport function balanceOrders<T extends PairedTime>(records: readonly T[]): Balanced<T> {\n const byCase = new Map<string, Record<Arm, number[]>>();\n records.forEach((record, index) => {\n const orders = byCase.get(record.case) ?? { a: [], b: [] };\n orders[record.first === \"b\" ? \"b\" : \"a\"].push(index);\n byCase.set(record.case, orders);\n });\n const drop = new Set<number>();\n const highFirst = (x: number, y: number): number => records[y]!.round - records[x]!.round;\n for (const { a, b } of byCase.values()) {\n const [more, fewer] = a.length > b.length ? [a, b] : [b, a];\n const extra = more.length - fewer.length - 1;\n if (extra > 0) for (const index of more.toSorted(highFirst).slice(0, extra)) drop.add(index);\n }\n return { records: records.filter((_, index) => !drop.has(index)), trimmed: drop.size };\n}\n\n/** The records of one job: the candidate pair and the A/A pair. */\nexport interface JobRecords {\n /** The label of the job, for example the index of its CI job. A record with a field `job` has this label, or `poolRecords` refuses it. */\n readonly job: string;\n readonly candidate: readonly PairedTime[];\n readonly aa: readonly PairedTime[];\n /** The cases that the job skipped, as `freshRun` gives them. `poolRecords` removes each of these cases from all jobs. */\n readonly skipped?: readonly { readonly case: string }[];\n}\n\n/** The records of one job in a pool: the cases that no job skipped, balanced with `balanceOrders`. */\nexport interface PooledJob {\n readonly job: string;\n readonly candidate: PairedTime[];\n readonly aa: PairedTime[];\n}\n\n/** The pool of the jobs: the merged records of all jobs, and the records of each job alone. */\nexport interface PooledRecords {\n /** The merged candidate records of all jobs, balanced with `balanceOrders`. */\n readonly candidate: PairedTime[];\n /** The merged A/A records of all jobs, balanced with `balanceOrders`. */\n readonly aa: PairedTime[];\n /** The records of each job alone, in the order of the jobs. */\n readonly jobs: readonly PooledJob[];\n /** The count of the records that `balanceOrders` removed from the merged candidate and A/A records. */\n readonly trimmed: number;\n /** The cases that a job skipped, in sorted order. The pool has no record of these cases. */\n readonly dropped: string[];\n}\n\n/**\n * This function gives the pool of the jobs. `pooledVerdict` and `pooledLimitVerdict` use it.\n * - It refuses two jobs with one label, and a record with a different job label. It also refuses two jobs with a record of one case and one round.\n * - It removes each case that a job skipped from all jobs, so all jobs have the same cases.\n * - It merges the records of the jobs, and it balances the merged records and the records of each job with `balanceOrders`.\n */\nexport function poolRecords(jobs: readonly JobRecords[]): PooledRecords {\n return pool(jobs, \"poolRecords\");\n}\n\n/** The pool of `poolRecords`. Each error starts with the name `caller`. */\nfunction pool(jobs: readonly JobRecords[], caller: string): PooledRecords {\n const labels = new Set<string>();\n for (const { job } of jobs) {\n if (labels.has(job)) throw new RangeError(`${caller}: two jobs have the label ${JSON.stringify(job)}.`);\n labels.add(job);\n }\n for (const { job, candidate: c, aa: a } of jobs) {\n for (const r of [...c, ...a] as readonly (PairedTime & { readonly job?: unknown })[]) {\n if (r.job !== undefined && r.job !== job) throw new RangeError(`${caller}: a record of the job ${JSON.stringify(job)} has the job ${JSON.stringify(r.job)}.`);\n }\n }\n const dropped = [...new Set(jobs.flatMap((j) => (j.skipped ?? []).map((s) => s.case)))].sort();\n const gone = new Set(dropped);\n const keep = (records: readonly PairedTime[]): PairedTime[] => records.filter((r) => !gone.has(r.case));\n const kept = jobs.map((j) => ({ job: j.job, candidate: keep(j.candidate), aa: keep(j.aa) }));\n uniqueRounds(kept, \"candidate\", caller);\n uniqueRounds(kept, \"aa\", caller);\n const candidate = balanceOrders(kept.flatMap((j) => j.candidate));\n const aa = balanceOrders(kept.flatMap((j) => j.aa));\n const each = kept.map(({ job, candidate: c, aa: a }): PooledJob => ({ job, candidate: balanceOrders(c).records, aa: balanceOrders(a).records }));\n return { candidate: candidate.records, aa: aa.records, jobs: each, trimmed: candidate.trimmed + aa.trimmed, dropped };\n}\n\n/** This function refuses two jobs with a record of one case and one round in one pair. */\nfunction uniqueRounds(jobs: readonly PooledJob[], pair: \"candidate\" | \"aa\", caller: string): void {\n const seen = new Map<string, string>();\n for (const { job, [pair]: records } of jobs) {\n for (const r of records) {\n const key = `${r.case}\\u0000${r.round}`;\n const other = seen.get(key);\n if (other !== undefined && other !== job) {\n throw new RangeError(\n `${caller}: the jobs ${JSON.stringify(other)} and ${JSON.stringify(job)} both have the round ${r.round} of the case ${JSON.stringify(r.case)} in the ${pair} pair. Set roundOffset of each job to job * rounds.`,\n );\n }\n seen.set(key, job);\n }\n }\n}\n\n/** The guard of a pooled verdict: the outcome, the opposed jobs and the reason. */\ninterface Guarded<O extends string> {\n readonly outcome: O | \"cannot decide\";\n readonly opposed: string[];\n readonly reason: string;\n}\n\n/**\n * This function applies the guard of the jobs to a pooled verdict. A job whose outcome is `opposite` of the pooled outcome\n * makes the outcome `cannot decide`. Each other job does not change the outcome.\n */\nfunction guard<O extends string>(\n pooled: { readonly outcome: O; readonly reason: string },\n jobs: readonly { readonly job: string; readonly verdict: { readonly outcome: O } }[],\n opposite: Partial<Record<O, O>>,\n): Guarded<O> {\n const against = opposite[pooled.outcome];\n const opposed = against === undefined ? [] : jobs.filter((j) => j.verdict.outcome === against).map((j) => j.job);\n if (opposed.length === 0) return { outcome: pooled.outcome, opposed, reason: pooled.reason };\n const names = opposed.map((j) => JSON.stringify(j)).join(\", \");\n const reason = `${pooled.reason} The pooled outcome is \"${pooled.outcome}\", but the jobs ${names} give \"${against}\". Thus the outcome is \"cannot decide\".`;\n return { outcome: \"cannot decide\", opposed, reason };\n}\n\n/** The verdict of one job alone. */\nexport interface JobVerdict {\n readonly job: string;\n readonly verdict: TimeVerdict;\n}\n\n/** The pooled verdict over the jobs, with the verdict of each job alone. */\nexport interface PooledVerdict {\n /** The outcome of the pooled verdict, or `cannot decide` when a job decides the opposite direction. */\n readonly outcome: TimeOutcome;\n /** The verdict of the merged and balanced records of all jobs. */\n readonly pooled: TimeVerdict;\n /** The verdict of each job alone, with the options of the pooled verdict. */\n readonly jobs: readonly JobVerdict[];\n /** The jobs whose own outcome is the opposite direction of the pooled outcome. */\n readonly opposed: string[];\n /** The count of the records that `balanceOrders` removed from the merged candidate and A/A records. */\n readonly trimmed: number;\n /** The cases that a job skipped, in sorted order. The verdicts use no record of these cases. */\n readonly dropped: string[];\n /** The reason of the pooled verdict, and the opposed jobs. */\n readonly reason: string;\n}\n\nconst opposite: Partial<Record<TimeOutcome, TimeOutcome>> = { faster: \"slower\", slower: \"faster\" };\n\n/**\n * This function gives the time verdict over the records of all jobs.\n * - It makes the pool of the jobs with `poolRecords`, and it gives the time verdict of the merged records.\n * - The verdict of each job alone uses the same options. A job with `cannot decide` or `same` does not change the outcome.\n * - A job that decides the opposite direction of the pooled outcome makes the outcome `cannot decide`.\n */\nexport function pooledVerdict(jobs: readonly JobRecords[], options: VerdictOptions = {}): PooledVerdict {\n const { candidate, aa, jobs: each, trimmed, dropped } = pool(jobs, \"pooledVerdict\");\n const pooled = timeVerdict(candidate, aa, options);\n const verdicts = each.map(({ job, candidate: c, aa: a }): JobVerdict => ({ job, verdict: timeVerdict(c, a, options) }));\n const { outcome, opposed, reason } = guard(pooled, verdicts, opposite);\n return { outcome, pooled, jobs: verdicts, opposed, trimmed, dropped, reason };\n}\n\n/** The limit verdict of one job alone. */\nexport interface JobLimitVerdict {\n readonly job: string;\n readonly verdict: LimitVerdict;\n}\n\n/** The pooled limit verdict over the jobs, with the limit verdict of each job alone. */\nexport interface PooledLimitVerdict {\n /** The outcome of the pooled limit verdict, or `cannot decide` when a job gives the opposite outcome. */\n readonly outcome: LimitOutcome;\n /** The limit verdict of the merged and balanced records of all jobs. */\n readonly pooled: LimitVerdict;\n /** The limit verdict of each job alone, with the options of the pooled verdict. */\n readonly jobs: readonly JobLimitVerdict[];\n /** The jobs whose own outcome is the opposite of the pooled outcome: `beyond` against `within`, or the reverse. */\n readonly opposed: string[];\n /** The count of the records that `balanceOrders` removed from the merged candidate and A/A records. */\n readonly trimmed: number;\n /** The cases that a job skipped, in sorted order. The verdicts use no record of these cases. */\n readonly dropped: string[];\n /** The reason of the pooled limit verdict, and the opposed jobs. */\n readonly reason: string;\n}\n\nconst limitOpposite: Partial<Record<LimitOutcome, LimitOutcome>> = { within: \"beyond\", beyond: \"within\" };\n\n/**\n * This function gives the limit verdict over the records of all jobs, for example for a speed gate on limits over a CI matrix.\n * - It makes the pool of the jobs with `poolRecords`, and it gives the limit verdict of the merged records.\n * - The verdict of each job alone uses the same options. A job with `cannot decide` does not change the outcome.\n * - A job with `beyond` against a pooled `within`, or the reverse, makes the outcome `cannot decide`.\n */\nexport function pooledLimitVerdict(jobs: readonly JobRecords[], options: LimitOptions): PooledLimitVerdict {\n const { candidate, aa, jobs: each, trimmed, dropped } = pool(jobs, \"pooledLimitVerdict\");\n const pooled = limitVerdict(candidate, aa, options);\n const verdicts = each.map(({ job, candidate: c, aa: a }): JobLimitVerdict => ({ job, verdict: limitVerdict(c, a, options) }));\n const { outcome, opposed, reason } = guard(pooled, verdicts, limitOpposite);\n return { outcome, pooled, jobs: verdicts, opposed, trimmed, dropped, reason };\n}\n\n/** The pairs of a run: the records of each pair, by the id of the pair. */\nexport interface RunPairs {\n readonly pairs: Readonly<Record<string, readonly PairedTime[]>>;\n}\n\n/**\n * This function gives the verdict of each candidate pair of a run against its A/A pair `aaPair`.\n * It balances the records of each pair with `balanceOrders` first. It refuses an `aaPair` that the run does not have.\n */\nexport function armVerdicts(run: RunPairs, aaPair: string, options: VerdictOptions = {}): Record<string, TimeVerdict> {\n const aaRecords = run.pairs[aaPair];\n if (aaRecords === undefined) throw new RangeError(`armVerdicts: the run has no pair ${JSON.stringify(aaPair)}.`);\n const aa = balanceOrders(aaRecords).records;\n const out: Record<string, TimeVerdict> = {};\n for (const [pair, records] of Object.entries(run.pairs)) {\n if (pair !== aaPair) out[pair] = timeVerdict(balanceOrders(records).records, aa, options);\n }\n return out;\n}\n","/**\n * The power test of a time verdict. It draws seeded benches with a known speedup and counts the verdicts that find it.\n * It also draws benches with equal arms and counts the false verdicts.\n */\nimport { random } from \"@mark1russell7/rigor-generators\";\nimport { firstArm, type PairedTime } from \"./paired.ts\";\nimport { type TimeOutcome, type VerdictOptions, timeVerdict, verdictMargin } from \"./verdict.ts\";\n\n/** The options of a power test. */\nexport interface PowerOptions {\n /** The count of the cases of the candidate and of the A/A arm. */\n readonly cases: number;\n /** The count of the rounds of each case. The default is 5. */\n readonly rounds?: number;\n /** The true ratio of the candidate time to the baseline time, for example 0.93 for a speedup of 7%. */\n readonly ratio: number;\n /** The standard deviation of the log time of one arm in one round. The default is 0.1. */\n readonly sigma?: number;\n /** The count of the seeded benches. The default is 200. */\n readonly trials?: number;\n /** The seed of the draws. The default is 1. */\n readonly seed?: number | string;\n /** The options of the verdict of each bench. */\n readonly verdict?: VerdictOptions;\n}\n\n/** The result of a power test: the share of each outcome over the trials. */\nexport interface Power {\n readonly trials: number;\n readonly outcomes: Readonly<Record<TimeOutcome, number>>;\n /**\n * The share of the trials whose outcome is the true one. For the rule `difference`, a ratio in the margin of the verdict has the true outcome `same`.\n * That margin is the larger of `margin` and the noise of the pooled band. The pool is the same in each trial, so each trial has the same margin.\n * Out of that margin, and for the rule `band`, the true outcome is `faster` below 1, `slower` above 1 and `same` at 1.\n */\n readonly power: number;\n}\n\n/**\n * This function draws `trials` benches and gives the share of each verdict. Each case has its own log scale.\n * Each arm of each round adds a normal noise of `sigma` to the log time.\n */\nexport function verdictPower(options: PowerOptions): Power {\n const rounds = options.rounds ?? 5;\n const sigma = options.sigma ?? 0.1;\n const trials = options.trials ?? 200;\n if (!Number.isSafeInteger(options.cases) || options.cases < 1) throw new RangeError(`verdictPower: cases is a whole number of 1 or more, not ${options.cases}.`);\n if (!(options.ratio > 0 && Number.isFinite(options.ratio))) throw new RangeError(`verdictPower: the ratio is a finite number above 0, not ${options.ratio}.`);\n const r = random(options.seed ?? 1);\n const bench = (ratio: number, prefix: string): PairedTime[] => {\n const out: PairedTime[] = [];\n for (let c = 0; c < options.cases; c++) {\n const scale = 10 * Math.exp(r.normal());\n for (let round = 0; round < rounds; round++) {\n const a = scale * Math.exp(r.normal(0, sigma));\n const b = scale * ratio * Math.exp(r.normal(0, sigma));\n out.push({ case: `${prefix}${c}`, round, first: firstArm(round, c), a, b });\n }\n }\n return out;\n };\n const truth = trueOutcome(options.ratio, options.verdict);\n const counts: Record<TimeOutcome, number> = { faster: 0, slower: 0, same: 0, \"cannot decide\": 0 };\n for (let t = 0; t < trials; t++) {\n const aa = bench(1, \"aa\");\n const candidate = bench(options.ratio, \"c\");\n counts[timeVerdict(candidate, aa, options.verdict).outcome]++;\n }\n const outcomes = Object.fromEntries(Object.entries(counts).map(([k, n]) => [k, n / trials])) as Record<TimeOutcome, number>;\n return { trials, outcomes, power: outcomes[truth] };\n}\n\n/** This function gives the true outcome of a ratio. The margin of the rule `difference` comes first, as in `timeVerdict`. */\nfunction trueOutcome(ratio: number, verdict: VerdictOptions = {}): TimeOutcome {\n if ((verdict.rule ?? \"difference\") === \"difference\" && Math.abs(Math.log(ratio)) <= verdictMargin(verdict)) return \"same\";\n return ratio < 1 ? \"faster\" : ratio > 1 ? \"slower\" : \"same\";\n}\n","/**\n * The timed rounds of one case in one process. The two arms first run for a warm-up time. Then the count of calls of\n * one batch grows until a batch of arm `a` takes the target time. Each round times one batch of each arm, in the order\n * of `firstArm`. Start this function in a fresh process for each case.\n */\nimport { type Arm, type PairedTime, firstArm } from \"./paired.ts\";\n\n/** The options of the timed rounds of one case. */\nexport interface RoundsOptions {\n /** The name of the case. */\n readonly case: string;\n /** The count of the rounds. */\n readonly rounds: number;\n /** The offset of `firstArm`: give the index of the case, so half of the cases start with each arm. The default is 0. */\n readonly offset?: number;\n /** The least time in milliseconds of one batch of arm `a`. The default is 10. */\n readonly targetMs?: number;\n /** The time in milliseconds of the warm-up of the two arms. The default is 1000. */\n readonly warmMs?: number;\n /** The clock in milliseconds. The default is `performance.now` of the global `performance` of Node and of each browser. */\n readonly now?: () => number;\n}\n\n/** The result of the timed rounds of one case. */\nexport interface Rounds {\n readonly records: PairedTime[];\n /** The count of calls of each arm in one batch. */\n readonly count: number;\n /** The sum of the numbers that the arms gave. The engine cannot remove the work of a call, because this sum uses it. */\n readonly sink: number;\n}\n\n/**\n * This function times the arms `a` and `b` of one case, and gives one `PairedTime` record for each round. The time of\n * a record is the time of one batch, in milliseconds. Each call of an arm gives a number, and the sum of these numbers\n * keeps the work.\n */\nexport function timeRounds(arms: Readonly<Record<Arm, () => number>>, options: RoundsOptions): Rounds {\n const { rounds } = options;\n const offset = options.offset ?? 0;\n const targetMs = options.targetMs ?? 10;\n const warmMs = options.warmMs ?? 1000;\n const now = options.now ?? (() => performance.now());\n if (!Number.isSafeInteger(rounds) || rounds < 1) throw new RangeError(`timeRounds: the rounds are a whole number of 1 or more, not ${rounds}.`);\n if (!Number.isSafeInteger(offset)) throw new RangeError(`timeRounds: the offset is a whole number, not ${offset}.`);\n if (!(targetMs > 0) || !(warmMs >= 0)) throw new RangeError(\"timeRounds: the target time is above 0, and the warm-up time is 0 or more.\");\n let sink = 0;\n const batch = (arm: Arm, count: number): number => {\n const run = arms[arm];\n const start = now();\n for (let i = 0; i < count; i++) sink += run();\n return now() - start;\n };\n let count = 1;\n const warmUntil = now() + warmMs;\n while (now() < warmUntil) {\n if (batch(\"a\", count) < targetMs / 4) count *= 2;\n batch(\"b\", count);\n }\n while (batch(\"a\", count) < targetMs) count *= 2;\n const records: PairedTime[] = [];\n for (let round = 0; round < rounds; round++) {\n const first = firstArm(round, offset);\n const second: Arm = first === \"a\" ? \"b\" : \"a\";\n const times = { [first]: batch(first, count), [second]: batch(second, count) } as Record<Arm, number>;\n records.push({ case: options.case, round, first, a: times.a, b: times.b });\n }\n return { records, count, sink };\n}\n"],"mappings":";;;;;;;;;;AA+DA,SAAS,cAAc,MAAc,QAAuD;CAC1F,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,sBAAM,IAAI,IAAsB;CACtC,KAAK,MAAM,KAAK,QAAQ;EACtB,IAAI,EAAE,OAAO,SAAS,EAAE,KAAK,KAAK,EAAE,SAAS,IAAI,MAAM,IAAI,WAAW,+BAA+B,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,gCAAgC,EAAE,MAAM,EAAE;E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,SAAS;CAC9C,MAAM,UAAwB,CAAC;CAC/B,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,SAAS;EAC3C,MAAM,QAAQ,SAAS,OAAO,MAAM;EACpC,MAAM,SAAc,UAAU,MAAM,MAAM;EAC1C,MAAM,QAAQ;IAAG,QAAQ,MAAM,OAAO,KAAK;IAAI,SAAS,MAAM,QAAQ,KAAK;EAAE;EAC7E,QAAQ,KAAK;GAAE,MAAM,QAAQ;GAAM;GAAO;GAAO,GAAG,MAAM;GAAG,GAAG,MAAM;EAAE,CAAC;CAC3E;CACA,OAAO;EAAE;EAAS;EAAO;CAAK;AAChC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["round","round"],"sources":["../src/budget.ts","../src/control.ts","../src/ladder.ts","../src/verdict.ts","../src/limit.ts","../src/merge.ts","../src/power.ts","../src/rounds.ts"],"sourcesContent":["/**\n * The budget verdict of one build: is the median of a measure of each case at most an absolute limit? An example is the\n * claim \"the median blocking time of this page is at most 450 ms\". The time verdict and the limit verdict judge a ratio\n * of two arms, so they cannot use a value of 0. Their A/A band is also a ratio.\n */\nimport { median, medianInterval } from \"@mark1russell7/rigor-statistics\";\n\n/** One value of one build on one case. The value is finite and 0 or more. */\nexport interface BudgetRound {\n /** The name of the case: one input of the bench. */\n readonly case: string;\n /** The number of the round, a whole number of 0 or more. */\n readonly round: number;\n readonly value: number;\n}\n\n/** The three outcomes of a budget verdict. */\nexport type BudgetOutcome = \"within\" | \"beyond\" | \"cannot decide\";\n\n/** The options of a budget verdict. */\nexport interface BudgetOptions {\n /** The largest median that the claim permits, in the unit of the values. */\n readonly limit: number;\n /** The largest difference between the medians of the two arms of the same build. A larger difference makes the run too noisy. */\n readonly maxDifference: number;\n /** The level of the interval of each median. The default is 0.95, which needs 6 rounds or more in each arm. */\n readonly caseLevel?: number;\n}\n\n/** The verdict of one case against the budget. */\nexport interface CaseBudget {\n readonly case: string;\n /** The number of rounds of the case. */\n readonly rounds: number;\n /** The number of rounds of the case in the A/A arm. */\n readonly aaRounds: number;\n readonly median: number;\n /** The median of the A/A arm, or undefined when the A/A arm does not have the case. */\n readonly aaMedian: number | undefined;\n /** The size of the difference between the two medians, or undefined when the A/A arm does not have the case. */\n readonly difference: number | undefined;\n /** The ends of the distribution-free interval of the median. */\n readonly low: number;\n readonly high: number;\n /** The coverage of the interval. Below the level, the case has too few rounds. */\n readonly coverage: number;\n readonly outcome: BudgetOutcome;\n /** The reason of the outcome, in one sentence, with the limit, the medians, the difference and the rounds. */\n readonly reason: string;\n}\n\n/** A budget verdict, with the facts that it uses. */\nexport interface BudgetVerdict {\n readonly outcome: BudgetOutcome;\n /** The reason of the outcome, in one sentence. */\n readonly reason: string;\n readonly limit: number;\n readonly maxDifference: number;\n readonly level: number;\n readonly cases: readonly CaseBudget[];\n}\n\n/** This function gives the values of each case, and it refuses a value out of range or a round that comes twice. */\nfunction valuesOfCases(name: string, rounds: readonly BudgetRound[]): Map<string, number[]> {\n const seen = new Set<string>();\n const out = new Map<string, number[]>();\n for (const r of rounds) {\n if (!(Number.isFinite(r.value) && r.value >= 0)) throw new RangeError(`budgetVerdict: the value of ${JSON.stringify(r.case)} in ${name} is finite and 0 or more, not ${r.value}.`);\n const key = JSON.stringify([r.case, r.round]);\n if (seen.has(key)) throw new RangeError(`budgetVerdict: the round ${r.round} of ${JSON.stringify(r.case)} comes twice in ${name}.`);\n seen.add(key);\n out.set(r.case, [...(out.get(r.case) ?? []), r.value]);\n }\n return out;\n}\n\n/** This function gives the verdict of one case. */\nfunction caseBudget(name: string, values: readonly number[], aaValues: readonly number[], options: BudgetOptions, level: number): CaseBudget {\n const { limit, maxDifference } = options;\n const interval = medianInterval(values, level);\n const middle = median(values);\n const aaMedian = aaValues.length > 0 ? median(aaValues) : undefined;\n const difference = aaMedian === undefined ? undefined : Math.abs(middle - aaMedian);\n const aaCoverage = aaValues.length > 0 ? medianInterval(aaValues, level).coverage : 0;\n const facts = `median ${round(middle)} of ${values.length} rounds, interval ${round(interval.low)} to ${round(interval.high)}, limit ${limit}, A/A median ${aaMedian === undefined ? \"none\" : round(aaMedian)} of ${aaValues.length} rounds, difference ${difference === undefined ? \"none\" : round(difference)}`;\n const decide = (outcome: BudgetOutcome, why: string): CaseBudget => ({\n case: name,\n rounds: values.length,\n aaRounds: aaValues.length,\n median: middle,\n aaMedian,\n difference,\n low: interval.low,\n high: interval.high,\n coverage: interval.coverage,\n outcome,\n reason: `The case ${JSON.stringify(name)} has the outcome \"${outcome}\": ${why} (${facts}).`,\n });\n if (difference === undefined) return decide(\"cannot decide\", \"the A/A arm does not have the case\");\n if (interval.coverage < level || aaCoverage < level) return decide(\"cannot decide\", `an arm has too few rounds for the level ${level}`);\n if (difference > maxDifference) return decide(\"cannot decide\", `the A/A difference is above ${maxDifference}`);\n if (interval.high <= limit) return decide(\"within\", \"the interval is at or below the limit\");\n if (interval.low > limit) return decide(\"beyond\", \"the interval is above the limit\");\n return decide(\"cannot decide\", \"the interval holds the limit\");\n}\n\n/**\n * This function gives the verdict of the claim \"the median of each case is at most `limit`\". The arm `aa` is a second\n * arm of the same build, and it shows the noise of the run as a difference. Values of 0 are valid.\n * - A case is `cannot decide` when the A/A arm does not have it, or when an arm has too few rounds for the level.\n * - A case is also `cannot decide` when the medians of the two arms differ by more than `maxDifference`.\n * - Other cases are `within` when the high end of the interval is at most the limit.\n * - They are `beyond` when the low end of the interval is above the limit.\n * - The verdict is `beyond` when a case is `beyond`, and `within` when each case is `within`.\n * - Each other verdict is `cannot decide`, and so is a verdict with no cases.\n */\nexport function budgetVerdict(rounds: readonly BudgetRound[], aa: readonly BudgetRound[], options: BudgetOptions): BudgetVerdict {\n const { limit, maxDifference } = options;\n const level = options.caseLevel ?? 0.95;\n if (!(limit >= 0 && Number.isFinite(limit))) throw new RangeError(`budgetVerdict: the limit is finite and 0 or more, not ${limit}.`);\n if (!(maxDifference >= 0 && Number.isFinite(maxDifference))) throw new RangeError(`budgetVerdict: the largest difference is finite and 0 or more, not ${maxDifference}.`);\n const values = valuesOfCases(\"the rounds\", rounds);\n const aaValues = valuesOfCases(\"the A/A arm\", aa);\n const cases = [...values.keys()].sort().map((name) => caseBudget(name, values.get(name) ?? [], aaValues.get(name) ?? [], options, level));\n return verdictOf(cases, { limit, maxDifference, level });\n}\n\n/** This function gives the verdict of a list of case verdicts. */\nfunction verdictOf(cases: readonly CaseBudget[], claim: Pick<BudgetVerdict, \"limit\" | \"maxDifference\" | \"level\">): BudgetVerdict {\n const facts = { ...claim, cases };\n if (cases.length === 0) return { outcome: \"cannot decide\", reason: \"The verdict has no cases.\", ...facts };\n const first = cases.find((c) => c.outcome === \"beyond\") ?? cases.find((c) => c.outcome === \"cannot decide\");\n if (first === undefined) {\n const top = cases.reduce((a, b) => (b.high > a.high ? b : a));\n return { outcome: \"within\", reason: `Each of the ${cases.length} cases is within. The largest is this one: ${top.reason}`, ...facts };\n }\n const count = cases.filter((c) => c.outcome === first.outcome).length;\n return { outcome: first.outcome, reason: `${count} of ${cases.length} cases have this outcome. The first is this one: ${first.reason}`, ...facts };\n}\n\n/** One look of a budget with looks: the rounds of each arm, and the level of the interval at those rounds. */\nexport interface BudgetLook {\n readonly rounds: number;\n readonly level: number;\n}\n\n/**\n * These looks start with 6 rounds, as `budgetVerdict` does, and they stop at 24. The three looks spend 0.0442 of the\n * overall 0.05. On the blocking times of a noisy web page, 97% of the runs with a median 16% under the limit stop by 24.\n */\nexport const BUDGET_LOOKS: readonly BudgetLook[] = [\n { rounds: 6, level: 0.95 },\n { rounds: 12, level: 0.99 },\n { rounds: 24, level: 0.99 },\n];\n\n/** The options of a budget verdict with looks. */\nexport interface BudgetLooksOptions {\n /** The largest median that the claim permits, in the unit of the values. */\n readonly limit: number;\n /** The largest difference between the medians of the two arms of the same build. */\n readonly maxDifference: number;\n /** The looks, with the rounds in rising order. The default is `BUDGET_LOOKS`. */\n readonly looks?: readonly BudgetLook[];\n /** The level over all looks of one case. The default is 0.95. */\n readonly level?: number;\n}\n\n/** The next look of one case: the rounds that each arm of the case needs. */\nexport interface BudgetMore {\n readonly case: string;\n readonly rounds: number;\n}\n\n/** A budget verdict with looks. The field `level` is the level over all looks. */\nexport interface BudgetLooksVerdict extends BudgetVerdict {\n /** The chance of error that the looks spend: the sum of 1 - coverage over the looks. */\n readonly spent: number;\n /** The cases with no outcome that can have another look. The list is empty when the verdict is final. */\n readonly more: readonly BudgetMore[];\n /** True only when the interval of a case is above the limit. A case with no outcome at the last look does not fail. */\n readonly fails: boolean;\n}\n\n/**\n * This function gives the chance of error that a list of looks spends: the sum of 1 - coverage of each look. This sum is\n * the Bonferroni bound over the looks. A look that has too few rounds for its level gives a `RangeError`.\n */\nexport function budgetLookSpend(looks: readonly BudgetLook[]): number {\n if (looks.length === 0) throw new RangeError(\"budgetLookSpend: the list of looks is empty.\");\n let spent = 0;\n let last = 0;\n for (const { rounds, level } of looks) {\n if (!(Number.isInteger(rounds) && rounds > last)) throw new RangeError(`budgetLookSpend: the rounds of the looks are whole numbers in rising order, not ${rounds} after ${last}.`);\n const { coverage } = medianInterval(\n Array.from({ length: rounds }, (_, i) => i),\n level,\n );\n if (coverage < level) throw new RangeError(`budgetLookSpend: ${rounds} rounds are too few for the level ${level}.`);\n spent += 1 - coverage;\n last = rounds;\n }\n return spent;\n}\n\n/** This function gives the outcome of one case: the first look with an outcome, or the last look that the rounds reach. */\nfunction caseAtLooks(name: string, values: readonly number[], aaValues: readonly number[], options: BudgetOptions, looks: readonly BudgetLook[]): { verdict: CaseBudget; next: number | undefined } {\n let verdict: CaseBudget | undefined;\n for (const { rounds, level } of looks) {\n if (values.length < rounds || aaValues.length < rounds) {\n return { verdict: verdict ?? caseBudget(name, values, aaValues, options, level), next: rounds };\n }\n verdict = caseBudget(name, values.slice(0, rounds), aaValues.slice(0, rounds), options, level);\n if (verdict.outcome !== \"cannot decide\") return { verdict, next: undefined };\n }\n return { verdict: verdict as CaseBudget, next: undefined };\n}\n\n/**\n * This function gives the budget verdict of a run that adds rounds. A caller gives all rounds so far, and it gets a\n * verdict and the field `more`. It adds the rounds of `more` to both arms, and it calls the function again.\n *\n * The chance of error of one look is 1 - coverage. The coverage is 1 - 2 P(X <= k - 1), for X ~ Binomial(n, 1/2) and\n * the rank k of the interval. The nominal level does not give this chance. The default looks have these figures:\n *\n * | Rounds n | Level | Rank k | Coverage | Chance of error |\n * | ---: | ---: | ---: | ---: | ---: |\n * | 6 | 0.95 | 1 | 0.96875 | 0.03125 |\n * | 12 | 0.99 | 2 | 0.99365 | 0.00635 |\n * | 24 | 0.99 | 6 | 0.99339 | 0.00661 |\n * | Sum | | | | 0.04421 |\n *\n * The sum is the Bonferroni bound over the looks. Each coverage needs independent rounds. Rounds with a shared cause, for\n * example a slow computer for one run, do not have that coverage.\n *\n * - The first look of a case with an outcome decides the case. Later rounds do not change it.\n * - Each look reads the rounds of that look in the order of their numbers. Thus a verdict comes again from its records.\n * - A sum of `budgetLookSpend` above 1 - `level` gives a `RangeError`, because many looks at one level spend too much.\n * - The field `fails` is true only for the outcome `beyond`. Tell a final `cannot decide` to the reader of the run.\n */\nexport function budgetLooksVerdict(rounds: readonly BudgetRound[], aa: readonly BudgetRound[], options: BudgetLooksOptions): BudgetLooksVerdict {\n const { limit, maxDifference } = options;\n const looks = options.looks ?? BUDGET_LOOKS;\n const level = options.level ?? 0.95;\n const spent = budgetLookSpend(looks);\n if (spent > 1 - level) throw new RangeError(`budgetLooksVerdict: the looks spend ${round(spent)}, over the ${round(1 - level)} of the level ${level}.`);\n if (!(limit >= 0 && Number.isFinite(limit))) throw new RangeError(`budgetLooksVerdict: the limit is finite and 0 or more, not ${limit}.`);\n if (!(maxDifference >= 0 && Number.isFinite(maxDifference))) throw new RangeError(`budgetLooksVerdict: the largest difference is finite and 0 or more, not ${maxDifference}.`);\n const byRound = (list: readonly BudgetRound[]): BudgetRound[] => [...list].sort((a, b) => a.round - b.round);\n const values = valuesOfCases(\"the rounds\", byRound(rounds));\n const aaValues = valuesOfCases(\"the A/A arm\", byRound(aa));\n const results = [...values.keys()].sort().map((name) => ({ name, ...caseAtLooks(name, values.get(name) ?? [], aaValues.get(name) ?? [], { limit, maxDifference }, looks) }));\n const verdict = verdictOf(\n results.map((r) => r.verdict),\n { limit, maxDifference, level },\n );\n const more = results.flatMap((r) => (r.next === undefined ? [] : [{ case: r.name, rounds: r.next }]));\n return { ...verdict, spent, more, fails: verdict.cases.some((c) => c.outcome === \"beyond\") };\n}\n\nfunction round(x: number): number {\n return Math.round(x * 10_000) / 10_000;\n}\n","/**\n * The load factor of a run, read from a control. Runs on shared machines differ by load. A change does not touch a control.\n * So the change of its time between two groups measures the machine and not the code.\n * The groups can be two runs, or the shards of one run.\n */\nimport { median, quantile } from \"@mark1russell7/rigor-statistics\";\n\n/** One time of the control in one group. */\nexport interface ControlRow {\n /** The name of the group: a run, or a shard of one run. */\n readonly group: string;\n /** The name of a class of work. The same key in two groups names equal work, so a ratio of the two measures the load. */\n readonly key: string;\n /** The time. It is finite and more than 0. */\n readonly value: number;\n /** This field is true when the run stopped the case at `value`. Thus the real time is at least `value`. */\n readonly censored?: boolean;\n}\n\n/** The options of `controlFactor`. */\nexport interface ControlOptions {\n /** The group that the factors compare with. Without it, the base of each key is the median of that key over the groups. */\n readonly base?: string;\n /** The least number of keys in a factor. A group with fewer keys has no factor. The default is 5. */\n readonly minPairs?: number;\n}\n\n/** The counts of one group, with or without a factor. */\nexport interface GroupCounts {\n readonly group: string;\n /** The number of keys that the factor reads. */\n readonly pairs: number;\n /** The number of keys that this function left out because a time of the key was censored. The factor reads low when this count is not 0. */\n readonly censored: number;\n /** The number of keys of this group that have no time to compare with, so no ratio reads them. */\n readonly unshared: number;\n}\n\n/** The factor of one group. */\nexport interface MeasuredFactor extends GroupCounts {\n /** The median ratio of the times of this group over the base. A factor of 1.6 means that this group took 1.6 times as long. */\n readonly factor: number;\n /** The quartiles of the ratios. A wide spread means that one factor does not explain the load. */\n readonly low: number;\n readonly high: number;\n}\n\n/** A group with too few usable keys. It has no factor, and the other groups keep theirs. */\nexport interface NoFactor extends GroupCounts {\n readonly factor: undefined;\n /** The reason that this group has no factor. */\n readonly reason: string;\n}\n\n/** The result of one group. Read `factor` first: a group with too few usable keys has no factor. */\nexport type GroupFactor = MeasuredFactor | NoFactor;\n\n/** The factors of a run, with the base that they use. */\nexport interface ControlFactors {\n /** The base group, or undefined when the base of each key is its median over the groups. */\n readonly base: string | undefined;\n readonly factors: readonly GroupFactor[];\n}\n\nconst DEFAULT_MIN_PAIRS = 5;\n\nfunction checkedRows(rows: readonly ControlRow[]): Map<string, Map<string, ControlRow>> {\n const groups = new Map<string, Map<string, ControlRow>>();\n for (const r of rows) {\n if (!(Number.isFinite(r.value) && r.value > 0)) throw new RangeError(`controlFactor: the value of ${JSON.stringify(r.key)} in ${JSON.stringify(r.group)} is finite and more than 0, not ${r.value}.`);\n const group = groups.get(r.group) ?? new Map<string, ControlRow>();\n if (group.has(r.key)) throw new RangeError(`controlFactor: the key ${JSON.stringify(r.key)} comes twice in ${JSON.stringify(r.group)}.`);\n group.set(r.key, r);\n groups.set(r.group, group);\n }\n return groups;\n}\n\nfunction factorOf(group: string, ratios: readonly number[], censored: number, unshared: number, minPairs: number): GroupFactor {\n const counts = { group, pairs: ratios.length, censored, unshared };\n if (ratios.length < minPairs) return { ...counts, factor: undefined, reason: `the group ${JSON.stringify(group)} has ${ratios.length} usable keys, and the least is ${minPairs}.` };\n return { ...counts, factor: median(ratios), low: quantile(ratios, 0.25), high: quantile(ratios, 0.75) };\n}\n\n/** This function refuses a result with no factor at all, because such a result measures nothing. */\nfunction withFactors(base: string | undefined, factors: readonly GroupFactor[]): ControlFactors {\n if (factors.every((f) => f.factor === undefined)) {\n const thin = factors.find((f): f is NoFactor => f.factor === undefined);\n throw new RangeError(`controlFactor: no group has a factor: ${thin?.reason ?? \"the rows hold no group to compare.\"}`);\n }\n return { base, factors };\n}\n\n/** This function gives the factors over one base group. Each factor reads the keys that the two groups share. */\nfunction againstGroup(groups: Map<string, Map<string, ControlRow>>, base: string, minPairs: number): ControlFactors {\n const baseRows = groups.get(base);\n if (baseRows === undefined) throw new RangeError(`controlFactor: the base ${JSON.stringify(base)} is not a group of the rows.`);\n const factors: GroupFactor[] = [];\n for (const [group, rows] of groups) {\n if (group === base) continue;\n const ratios: number[] = [];\n let censored = 0;\n let unshared = 0;\n for (const [key, r] of rows) {\n const b = baseRows.get(key);\n if (b === undefined) unshared += 1;\n else if (r.censored === true || b.censored === true) censored += 1;\n else ratios.push(r.value / b.value);\n }\n factors.push(factorOf(group, ratios, censored, unshared, minPairs));\n }\n return withFactors(base, factors);\n}\n\n/**\n * This function gives the factors over the median of each key, as one run grouped by shard needs.\n * Each group holds a different mix of work, so a time compares only with the times of the same key. A key in one group has nothing to compare with.\n */\nfunction againstKeys(groups: Map<string, Map<string, ControlRow>>, minPairs: number): ControlFactors {\n const clean = new Map<string, number[]>();\n for (const rows of groups.values()) {\n for (const [key, r] of rows) if (r.censored !== true) clean.set(key, [...(clean.get(key) ?? []), r.value]);\n }\n const factors = [...groups].map(([group, rows]) => {\n const ratios: number[] = [];\n let censored = 0;\n let unshared = 0;\n for (const [key, r] of rows) {\n const times = clean.get(key) ?? [];\n if (r.censored === true) censored += 1;\n else if (times.length >= 2) ratios.push(r.value / median(times));\n else unshared += 1;\n }\n return factorOf(group, ratios, censored, unshared, minPairs);\n });\n return withFactors(undefined, factors);\n}\n\n/**\n * This function gives the load factor of each group from the times of a control.\n *\n * With `base`, a factor compares the keys that a group shares with that group. Without it, a factor compares each time with the median of its key over the groups.\n * A key names a class of work, so equal keys in two groups mean equal work. Each group has at most one row for a key.\n *\n * A censored time is only a lower limit, so no ratio reads it, and the result counts those keys. A run stops its slowest cases, so a factor reads low when `censored` is not 0.\n *\n * A group with too few usable keys gets an entry with no factor and its reason, so the other groups keep their factors. This function refuses a result where no group has a factor.\n */\nexport function controlFactor(rows: readonly ControlRow[], options: ControlOptions = {}): ControlFactors {\n const minPairs = options.minPairs ?? DEFAULT_MIN_PAIRS;\n if (!(Number.isInteger(minPairs) && minPairs >= 1)) throw new RangeError(`controlFactor: minPairs is a whole number of 1 or more, not ${minPairs}.`);\n const groups = checkedRows(rows);\n return options.base === undefined ? againstKeys(groups, minPairs) : againstGroup(groups, options.base, minPairs);\n}\n","/**\n * The scale ladder of a product, as data. A ladder has rungs at sizes that grow, for example 1, 10 and 100 tenants. Each\n * rung has budgets, and it names the test that holds it. A rung is held only when a record of that test shows each budget\n * `within`. A number in a document is not a rung.\n */\nimport { quantile, quantileInterval, quantileSamples, wilson } from \"@mark1russell7/rigor-statistics\";\nimport { type BudgetOutcome, type BudgetRound, budgetVerdict } from \"./budget.ts\";\n\n/** The format name of a ladder. It changes when a reader of an older form cannot read the data. */\nexport const LADDER_FORMAT = \"rigor-ladder/1\";\n\n/** One dimension of a ladder, for example tenants or nodes. */\nexport interface LadderDimension {\n readonly name: string;\n /** What one unit of the dimension is, in plain words. */\n readonly describe: string;\n}\n\n/** A budget on the median of each case, for example the time of a read. A record gives rounds and an A/A arm. */\nexport interface MedianBudget {\n readonly kind: \"median\";\n readonly measure: string;\n /** The unit of the limit and of the values. */\n readonly unit: string;\n /** The largest median that the budget permits. */\n readonly limit: number;\n /** The largest difference between the medians of the two arms. A larger difference makes the run too noisy. */\n readonly maxDifference: number;\n /** The level of the interval of each median. The default is 0.95. */\n readonly caseLevel?: number;\n}\n\n/** A budget on the share of failed trials, for example failed requests. A record gives failures and trials. */\nexport interface RateBudget {\n readonly kind: \"rate\";\n readonly measure: string;\n /** The largest share of failures that the budget permits, from 0 to 1. */\n readonly limit: number;\n}\n\n/** A budget on the largest value of a set of drills, for example the writes that a restore lost. One bad drill is `beyond`. */\nexport interface WorstBudget {\n readonly kind: \"worst\";\n readonly measure: string;\n readonly unit: string;\n /** The largest value that the budget permits in any drill. */\n readonly limit: number;\n /** The number of drills that a verdict needs, 1 or more. With fewer, the budget is `cannot decide`. */\n readonly minDrills: number;\n}\n\n/**\n * A budget on a high quantile, for example the p99 of a read. A record gives the values. The verdict is the distribution-free\n * interval of the quantile against the limit. A p99 needs 368 independent values at the level 0.95: refer to `quantileSamples`.\n * Successive times of one run can follow each other. Space them apart, or give one value for each run.\n *\n * The evidence can also hold `censored`: a lower bound for each arrival with no reply, and for each arrival that was not\n * sent. The bound is the time that the arrival waited. The true value is that bound or more, with no upper limit. Thus the\n * low end of the interval reads the bounds, and the high end reads each censored value as `Infinity`. A `beyond` stays\n * provable from the bounds alone. A `within` needs real replies up to the upper rank of the interval.\n */\nexport interface QuantileBudget {\n readonly kind: \"quantile\";\n readonly measure: string;\n /** The unit of the limit and of the values. */\n readonly unit: string;\n /** The quantile, more than 0 and less than 1, for example 0.99. */\n readonly quantile: number;\n /** The largest quantile that the budget permits. */\n readonly limit: number;\n /** The level of the interval. The default is 0.95. */\n readonly level?: number;\n}\n\n/** One budget of a rung. */\nexport type RungBudget = MedianBudget | QuantileBudget | RateBudget | WorstBudget;\n\n/** One rung of a ladder. */\nexport interface Rung {\n /** The name of the rung, unique in the ladder. */\n readonly name: string;\n /** The size of the rung in each dimension that it names. */\n readonly at: Readonly<Record<string, number>>;\n readonly budgets: readonly RungBudget[];\n /** The name of the automatic test that holds the rung. */\n readonly test: string;\n /** True when a gate holds the rung: the verdict fails when the rung is not `within`. */\n readonly locked?: boolean;\n}\n\n/** The ladder of one subject. The rungs go from the smallest to the largest. */\nexport interface Ladder {\n readonly format: typeof LADDER_FORMAT;\n /** The product or the service that the ladder is for. */\n readonly subject: string;\n readonly dimensions: readonly LadderDimension[];\n readonly rungs: readonly Rung[];\n}\n\n/** The measured evidence for one budget. Its `kind` is the kind of the budget. */\nexport type RungEvidence =\n | { readonly kind: \"median\"; readonly measure: string; readonly rounds: readonly BudgetRound[]; readonly aa: readonly BudgetRound[] }\n | { readonly kind: \"quantile\"; readonly measure: string; readonly values: readonly number[]; readonly censored?: readonly number[] }\n | { readonly kind: \"rate\"; readonly measure: string; readonly failures: number; readonly trials: number }\n | { readonly kind: \"worst\"; readonly measure: string; readonly values: readonly number[] };\n\n/** One run of the test of a rung. */\nexport interface RungRecord {\n /** The name of the rung. */\n readonly rung: string;\n /** The commit that the run measured. */\n readonly commit: string;\n /** The time of the run, as an ISO 8601 string. */\n readonly at: string;\n /** What the run did for real, for example \"2 processes\" or \"a restore from a real backup\". */\n readonly real: readonly string[];\n /** What the run made up, for example \"90 % of the tenants as data at rest\". An empty list states that nothing was synthetic. */\n readonly synthetic: readonly string[];\n readonly evidence: readonly RungEvidence[];\n}\n\n/** The verdict of one budget of a rung. */\nexport interface BudgetResult {\n readonly measure: string;\n readonly outcome: BudgetOutcome;\n /** The reason of the outcome, in one sentence, with the numbers. */\n readonly reason: string;\n}\n\n/** The verdict of one rung. */\nexport interface RungVerdict {\n readonly rung: string;\n readonly test: string;\n readonly locked: boolean;\n readonly outcome: BudgetOutcome;\n /** The reason of the outcome, in one sentence. */\n readonly reason: string;\n readonly budgets: readonly BudgetResult[];\n /** The commit of the record, or undefined when the rung has no record. */\n readonly commit: string | undefined;\n readonly real: readonly string[];\n readonly synthetic: readonly string[];\n}\n\n/** The verdict of a ladder. */\nexport interface LadderVerdict {\n readonly subject: string;\n /** The highest rung with each rung up to it `within`, or undefined when the first rung is not `within`. */\n readonly held: string | undefined;\n /** The first rung that is not `within`, or undefined when each rung is `within`. */\n readonly next: string | undefined;\n /** True when a locked rung is not `within`. A rung with no result is not held, so `cannot decide` fails too. */\n readonly failed: boolean;\n /** The reason of `failed`, in one sentence. */\n readonly reason: string;\n readonly rungs: readonly RungVerdict[];\n}\n\n/** The options of a ladder verdict. */\nexport interface LadderOptions {\n /** The time of the verdict, as an ISO 8601 string. It is an input, so that a verdict is the same at each read. */\n readonly now: string;\n /** The largest age of a record, in days. An older record gives `cannot decide`. The default accepts any age. */\n readonly maxAgeDays?: number;\n}\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n\n/** This function gives the problems of one budget. */\nfunction budgetProblems(where: string, budget: RungBudget): string[] {\n const out: string[] = [];\n const name = `${where}, budget ${JSON.stringify(budget.measure)}`;\n if (budget.measure.trim() === \"\") out.push(`${where}: a budget has no measure.`);\n if (!(Number.isFinite(budget.limit) && budget.limit >= 0)) out.push(`${name}: the limit is finite and 0 or more, not ${budget.limit}.`);\n if (budget.kind === \"rate\" && budget.limit > 1) out.push(`${name}: a rate limit is at most 1, not ${budget.limit}.`);\n if (budget.kind === \"median\" && !(Number.isFinite(budget.maxDifference) && budget.maxDifference >= 0)) {\n out.push(`${name}: the largest difference is finite and 0 or more, not ${budget.maxDifference}.`);\n }\n if (budget.kind === \"worst\" && !(Number.isInteger(budget.minDrills) && budget.minDrills >= 1)) {\n out.push(`${name}: the number of drills is a whole number of 1 or more, not ${budget.minDrills}.`);\n }\n if (budget.kind === \"quantile\" && !(budget.quantile > 0 && budget.quantile < 1)) out.push(`${name}: a quantile is more than 0 and less than 1, not ${budget.quantile}.`);\n if (budget.kind === \"quantile\" && budget.level !== undefined && !(budget.level > 0 && budget.level < 1)) out.push(`${name}: a level is more than 0 and less than 1, not ${budget.level}.`);\n return out;\n}\n\n/** This function gives the problems of one rung, in the order of its fields. */\nfunction rungProblems(rung: Rung, dimensions: ReadonlySet<string>): string[] {\n const where = `The rung ${JSON.stringify(rung.name)}`;\n const out: string[] = [];\n const names = Object.keys(rung.at);\n if (names.length === 0) out.push(`${where} names no dimension.`);\n for (const name of names) {\n if (!dimensions.has(name)) out.push(`${where} names the unknown dimension ${JSON.stringify(name)}.`);\n const size = rung.at[name];\n if (!(typeof size === \"number\" && Number.isFinite(size) && size > 0)) out.push(`${where}: the size of ${JSON.stringify(name)} is finite and above 0, not ${size}.`);\n }\n if (rung.test.trim() === \"\") out.push(`${where} names no test.`);\n if (rung.budgets.length === 0) out.push(`${where} has no budgets.`);\n const measures = new Set<string>();\n for (const budget of rung.budgets) {\n if (measures.has(budget.measure)) out.push(`${where} has two budgets of ${JSON.stringify(budget.measure)}.`);\n measures.add(budget.measure);\n out.push(...budgetProblems(where, budget));\n }\n return out;\n}\n\n/**\n * This function gives each problem of a ladder as data, or an empty list. A ladder needs a subject, one dimension or more,\n * and one rung or more. Names are unique. Each rung names a test and has budgets. From one rung to the next, each dimension\n * that the two rungs name grows.\n */\nexport function checkLadder(ladder: Ladder): readonly string[] {\n const out: string[] = [];\n if (ladder.format !== LADDER_FORMAT) out.push(`The format is ${JSON.stringify(LADDER_FORMAT)}, not ${JSON.stringify(ladder.format)}.`);\n if (ladder.subject.trim() === \"\") out.push(\"The ladder has no subject.\");\n if (ladder.dimensions.length === 0) out.push(\"The ladder has no dimensions.\");\n if (ladder.rungs.length === 0) out.push(\"The ladder has no rungs.\");\n const dimensions = new Set(ladder.dimensions.map((d) => d.name));\n if (dimensions.size !== ladder.dimensions.length) out.push(\"Two dimensions have the same name.\");\n if (new Set(ladder.rungs.map((r) => r.name)).size !== ladder.rungs.length) out.push(\"Two rungs have the same name.\");\n ladder.rungs.forEach((rung, index) => {\n out.push(...rungProblems(rung, dimensions));\n const before = ladder.rungs[index - 1];\n if (before === undefined) return;\n for (const [name, size] of Object.entries(rung.at)) {\n const low = before.at[name];\n if (low !== undefined && !(size > low)) out.push(`The rung ${JSON.stringify(rung.name)}: ${JSON.stringify(name)} does not grow from ${low} to ${size}.`);\n }\n });\n return out;\n}\n\n/** This function gives the verdict of a rate: the Wilson interval at 95 % against the limit. */\nfunction rateResult(budget: RateBudget, failures: number, trials: number): BudgetResult {\n const interval = wilson(failures, trials);\n const facts = `${failures} failures of ${trials} trials, interval ${interval.low} to ${interval.high}, limit ${budget.limit}`;\n const outcome: BudgetOutcome = trials === 0 ? \"cannot decide\" : interval.high <= budget.limit ? \"within\" : interval.low > budget.limit ? \"beyond\" : \"cannot decide\";\n return { measure: budget.measure, outcome, reason: `The measure ${JSON.stringify(budget.measure)} is \"${outcome}\" (${facts}).` };\n}\n\n/** This function gives the verdict of a set of drills: the largest value against the limit. */\nfunction worstResult(budget: WorstBudget, values: readonly number[]): BudgetResult {\n const largest = values.length === 0 ? undefined : Math.max(...values);\n const facts = `${values.length} drills, the largest ${largest ?? \"none\"} ${budget.unit}, limit ${budget.limit}`;\n const outcome: BudgetOutcome = largest !== undefined && largest > budget.limit ? \"beyond\" : values.length < budget.minDrills ? \"cannot decide\" : \"within\";\n return { measure: budget.measure, outcome, reason: `The measure ${JSON.stringify(budget.measure)} is \"${outcome}\" (${facts}, ${budget.minDrills} drills needed).` };\n}\n\n/**\n * This function gives the verdict of a quantile: its distribution-free interval against the limit. With censored values, the\n * low end reads their bounds and the high end reads them as `Infinity`. Each true sample has its interval inside that one.\n */\nfunction quantileResult(budget: QuantileBudget, values: readonly number[], censored: readonly number[]): BudgetResult {\n const level = budget.level ?? 0.95;\n const needed = quantileSamples(budget.quantile, level);\n const say = (outcome: BudgetOutcome, facts: string): BudgetResult => ({ measure: budget.measure, outcome, reason: `The measure ${JSON.stringify(budget.measure)} is \"${outcome}\" (${facts}, ${needed} values needed).` });\n const open = censored.length > 0;\n const bounds = [...values, ...censored];\n if (bounds.length === 0) return say(\"cannot decide\", `0 values, limit ${budget.limit} ${budget.unit}`);\n if (values.some((value) => Number.isNaN(value))) return say(\"cannot decide\", \"the values have a NaN\");\n if (!censored.every((value) => Number.isFinite(value))) return say(\"cannot decide\", \"a censored value is not a finite number\");\n const lowest = quantileInterval(bounds, budget.quantile, level);\n const highest = open ? quantileInterval([...values, ...censored.map(() => Infinity)], budget.quantile, level) : lowest;\n const [count, point] = open ? [`${values.length} values and ${censored.length} censored`, \"at least\"] : [`${values.length} values`, \"at\"];\n const facts = `${count}, quantile ${budget.quantile} ${point} ${quantile(bounds, budget.quantile, \"nearest-rank\")} ${budget.unit}, interval ${lowest.low} to ${highest.high}, limit ${budget.limit}`;\n return say(highest.high <= budget.limit ? \"within\" : lowest.low > budget.limit ? \"beyond\" : \"cannot decide\", facts);\n}\n\n/** This function gives the verdict of one budget from the evidence of a record. */\nfunction budgetResult(budget: RungBudget, evidence: readonly RungEvidence[]): BudgetResult {\n const found = evidence.find((e) => e.measure === budget.measure);\n const none = (why: string): BudgetResult => ({ measure: budget.measure, outcome: \"cannot decide\", reason: `The measure ${JSON.stringify(budget.measure)} is \"cannot decide\": ${why}.` });\n if (found === undefined) return none(\"the record has no evidence for it\");\n if (budget.kind === \"median\" && found.kind === \"median\") {\n const v = budgetVerdict(found.rounds, found.aa, { limit: budget.limit, maxDifference: budget.maxDifference, ...(budget.caseLevel === undefined ? {} : { caseLevel: budget.caseLevel }) });\n return { measure: budget.measure, outcome: v.outcome, reason: v.reason };\n }\n if (budget.kind === \"quantile\" && found.kind === \"quantile\") return quantileResult(budget, found.values, found.censored ?? []);\n if (budget.kind === \"rate\" && found.kind === \"rate\") return rateResult(budget, found.failures, found.trials);\n if (budget.kind === \"worst\" && found.kind === \"worst\") return worstResult(budget, found.values);\n return none(`the budget is ${budget.kind}, and the evidence is ${found.kind}`);\n}\n\n/** This function gives the reason that a record cannot decide a rung, or undefined when the record can. */\nfunction recordProblem(record: RungRecord, options: LadderOptions): string | undefined {\n if (record.real.length === 0) return \"the record does not state what was real\";\n const { maxAgeDays } = options;\n if (maxAgeDays === undefined) return undefined;\n const age = (Date.parse(options.now) - Date.parse(record.at)) / DAY_MS;\n if (!Number.isFinite(age)) return `a time does not parse: now ${options.now}, record ${record.at}`;\n return age > maxAgeDays ? `the record of ${record.at} is older than ${maxAgeDays} days` : undefined;\n}\n\n/** This function gives the outcome of a set of budgets: `beyond` first, then `cannot decide`, and `within` only when each budget is. */\nfunction worstOutcome(results: readonly BudgetResult[]): BudgetOutcome {\n if (results.some((r) => r.outcome === \"beyond\")) return \"beyond\";\n return results.length > 0 && results.every((r) => r.outcome === \"within\") ? \"within\" : \"cannot decide\";\n}\n\n/** This function gives the verdict of one rung from its record. With no record, the rung is `cannot decide`. */\nexport function rungVerdict(rung: Rung, record: RungRecord | undefined, options: LadderOptions): RungVerdict {\n const base = { rung: rung.name, test: rung.test, locked: rung.locked === true };\n if (record === undefined) {\n return { ...base, outcome: \"cannot decide\", reason: `The rung ${JSON.stringify(rung.name)} has no record of the test ${JSON.stringify(rung.test)}.`, budgets: [], commit: undefined, real: [], synthetic: [] };\n }\n const facts = { commit: record.commit, real: record.real, synthetic: record.synthetic };\n const problem = recordProblem(record, options);\n if (problem !== undefined) return { ...base, ...facts, outcome: \"cannot decide\", reason: `The rung ${JSON.stringify(rung.name)} is \"cannot decide\": ${problem}.`, budgets: [] };\n const budgets = rung.budgets.map((b) => budgetResult(b, record.evidence));\n const outcome = worstOutcome(budgets);\n const first = budgets.find((b) => b.outcome === outcome);\n return { ...base, ...facts, outcome, reason: outcome === \"within\" ? `The ${budgets.length} budgets of the rung ${JSON.stringify(rung.name)} are within.` : `The rung ${JSON.stringify(rung.name)} is \"${outcome}\". ${first?.reason ?? \"\"}`, budgets };\n}\n\n/** This function gives the newest record of each rung. It keeps the first of two records with the same time. */\nfunction newestRecords(records: readonly RungRecord[]): Map<string, RungRecord> {\n const out = new Map<string, RungRecord>();\n for (const record of records) {\n const old = out.get(record.rung);\n if (old === undefined || Date.parse(record.at) > Date.parse(old.at)) out.set(record.rung, record);\n }\n return out;\n}\n\n/**\n * This function gives the verdict of a ladder from the records of its rungs. It uses the newest record of each rung, so an\n * older pass does not hide a newer failure. A rung high up does not count when a rung below it is not `within`. It throws\n * a `RangeError` for a ladder with problems, because a verdict on a bad ladder has no meaning. See `checkLadder`.\n */\nexport function ladderVerdict(ladder: Ladder, records: readonly RungRecord[], options: LadderOptions): LadderVerdict {\n const problems = checkLadder(ladder);\n if (problems.length > 0) throw new RangeError(`ladderVerdict: ${problems.join(\" \")}`);\n const newest = newestRecords(records);\n const rungs = ladder.rungs.map((r) => rungVerdict(r, newest.get(r.name), options));\n const firstOpen = rungs.findIndex((r) => r.outcome !== \"within\");\n const heldCount = firstOpen === -1 ? rungs.length : firstOpen;\n const lost = rungs.filter((r) => r.locked && r.outcome !== \"within\");\n const reason = lost.length === 0 ? `Each of the ${rungs.filter((r) => r.locked).length} locked rungs is within.` : `${lost.length} locked rungs are not within. ${lost[0]?.reason ?? \"\"}`;\n return { subject: ladder.subject, held: rungs[heldCount - 1]?.rung, next: rungs[heldCount]?.rung, failed: lost.length > 0, reason, rungs };\n}\n","/**\n * The time verdict of a candidate against a baseline, with the noise of an A/A arm. An A/A pair runs the same code in\n * its two arms. Its ratios show how far apart two equal arms come on this machine. A candidate is faster or slower only\n * when its interval is out of that band.\n */\nimport { type BootstrapOptions, type Comparison, type Interval, bootstrapMedian, bootstrapTwo, compareRatios, median, quantile } from \"@mark1russell7/rigor-statistics\";\nimport { type CaseRatio, type PairedTime, caseRatios } from \"./paired.ts\";\n\n/**\n * The two kinds of an A/A band.\n * - The band `case` holds the ratio of one A/A case. It is wide, so it finds only a large change.\n * - The band `median` holds the median ratio of the A/A cases. It has the scale of the median of the candidate.\n */\nexport type BandKind = \"case\" | \"median\";\n\n/** The options of the A/A band. */\nexport interface BandOptions {\n /** The kind of the band. The default is `median`, from the power test of `verdictPower`. */\n readonly kind?: BandKind;\n /** The quantile of the band `case`, or the level of the bootstrap of the band `median`. The default is 0.95. */\n readonly level?: number;\n /** The fewest A/A cases that give a band. The default is 5, the 5-seed rule. */\n readonly minimum?: number;\n /** The bootstrap of the band `median`. The level of the band replaces its level. */\n readonly bootstrap?: BootstrapOptions;\n}\n\n/** The band of the A/A arm: two equal arms come out in this band of ratios. */\nexport interface Band {\n /** The count of the A/A cases. */\n readonly cases: number;\n readonly kind: BandKind;\n /**\n * The half width of the band on a log scale.\n * For the band `case`, it is the `level` quantile of `abs(log(ratio))` over the A/A cases.\n * For the band `median`, it is the larger distance of an end of the bootstrap interval of the A/A median from 0.\n */\n readonly noise: number;\n /** The ends of the band: `exp(-noise)` and `exp(noise)`. */\n readonly low: number;\n readonly high: number;\n /** The median ratio of the A/A cases. A value far from 1 shows a bias of the order or of the arm slots. */\n readonly median: number;\n}\n\n/** This function gives the band of the A/A arm. The band is symmetric on a log scale. It refuses fewer cases than `minimum`. */\nexport function aaBand(aa: readonly PairedTime[], options: BandOptions = {}): Band {\n const ratios = caseRatios(aa);\n const minimum = options.minimum ?? 5;\n if (ratios.length < minimum) throw new RangeError(`aaBand: the A/A arm has ${ratios.length} cases, and a band needs ${minimum} or more.`);\n const logs = ratios.map((r) => Math.log(r.ratio));\n const kind = options.kind ?? \"median\";\n const level = options.level ?? 0.95;\n let noise: number;\n if (kind === \"case\") noise = quantile(logs.map(Math.abs), level);\n else {\n const interval = bootstrapMedian(logs, { ...options.bootstrap, level });\n noise = Math.max(Math.abs(interval.low), Math.abs(interval.high));\n }\n return { cases: ratios.length, kind, noise, low: Math.exp(-noise), high: Math.exp(noise), median: Math.exp(quantile(logs, 0.5)) };\n}\n\n/**\n * This function gives the A/A spread: the `level` quantile of `abs(log(ratio))` over the A/A cases. The default level is 0.9.\n * It refuses an A/A arm with no cases.\n */\nexport function aaSpread(aa: readonly PairedTime[], level = 0.9): number {\n const ratios = caseRatios(aa);\n if (ratios.length === 0) throw new RangeError(\"aaSpread: the A/A arm has no cases.\");\n return spreadOf(ratios, level);\n}\n\nfunction spreadOf(ratios: readonly CaseRatio[], level: number): number {\n return quantile(ratios.map((r) => Math.abs(Math.log(r.ratio))), level);\n}\n\n/** The options of a pooled band: the A/A records of earlier quiet runs, and a floor. The caller keeps the pool. */\nexport interface PoolOptions {\n /** The A/A records of the earlier runs. Give each run its own case names, for example with the run id as a prefix. */\n readonly records: readonly PairedTime[];\n /** The smallest noise of the band, on a log scale. The default is 0. A floor of `Math.log(1.05)` gives at least the band `[1 / 1.05, 1.05]`. */\n readonly floor?: number;\n /** The fewest pooled cases that give a spread. With fewer cases, the noise of the band is the floor. The default is 5. */\n readonly minimum?: number;\n /**\n * The run of a record, for example the id of its CI run. The verdict counts the runs of the pool with it.\n * The cases of one run share one runner, so they are not independent. Many cases from few runs show the noise of few runners.\n */\n readonly run?: (record: PairedTime) => string;\n}\n\n/** The facts of the pooled band of a verdict. */\nexport interface PoolFacts {\n /** The count of the pooled A/A cases. */\n readonly cases: number;\n /** The count of the runs of the pool, from the option `run`. It is undefined without that option. */\n readonly runs: number | undefined;\n /** The A/A spread of the pooled cases, or undefined when the pool has fewer cases than `minimum`. */\n readonly spread: number | undefined;\n readonly floor: number;\n /** This value is `true` when the spread of the pool is larger than the floor, so the spread gives the noise of the band. */\n readonly pooled: boolean;\n}\n\n/**\n * This function gives the pooled band of the kind `case`. Its noise is the larger of the floor and the A/A spread of the pooled records.\n * The spread is the `level` quantile of `abs(log(ratio))`, with the default level 0.9.\n *\n * A band with fewer pooled cases than `minimum` uses the floor alone. A band with no pooled cases has the median 1.\n */\nexport function pooledBand(pool: PoolOptions, level = 0.9): Band {\n return poolOf(pool, level).band;\n}\n\nfunction poolOf(pool: PoolOptions, level: number): { band: Band; facts: PoolFacts } {\n const floor = pool.floor ?? 0;\n const minimum = pool.minimum ?? 5;\n if (!(floor >= 0 && Number.isFinite(floor))) throw new RangeError(`pooledBand: the floor is a finite number of 0 or more, not ${floor}.`);\n if (!Number.isSafeInteger(minimum) || minimum < 1) throw new RangeError(`pooledBand: the minimum is a whole number of 1 or more, not ${minimum}.`);\n const ratios = caseRatios(pool.records);\n const spread = ratios.length >= minimum ? spreadOf(ratios, level) : undefined;\n const noise = Math.max(floor, spread ?? 0);\n const median = ratios.length === 0 ? 1 : Math.exp(quantile(ratios.map((r) => Math.log(r.ratio)), 0.5));\n const band: Band = { cases: ratios.length, kind: \"case\", noise, low: Math.exp(-noise), high: Math.exp(noise), median };\n const runs = pool.run === undefined ? undefined : new Set(pool.records.map(pool.run)).size;\n return { band, facts: { cases: ratios.length, runs, spread, floor, pooled: spread !== undefined && spread > floor } };\n}\n\n/** The four outcomes of a time verdict. The candidate is the arm `b`, so `faster` is a ratio below 1. */\nexport type TimeOutcome = \"faster\" | \"slower\" | \"same\" | \"cannot decide\";\n\n/** The options of a time verdict. The bootstrap gives the interval of the median ratio of the candidate, and the band `median`. */\n/**\n * The two rules of a time verdict.\n * - The rule `band` compares the interval of the median ratio of the candidate with the A/A band.\n * - The rule `difference` compares the interval of the candidate median over the A/A median with 1 and with `margin`.\n */\nexport type VerdictRule = \"band\" | \"difference\";\n\n/** The options of a time verdict. The bootstrap gives each interval of the verdict. */\nexport interface VerdictOptions extends BandOptions {\n /** The rule of the verdict. The default is `difference`, from the power test of `verdictPower`. */\n readonly rule?: VerdictRule;\n /**\n * The half width on a log scale of the ratios that the rule `difference` calls `same`. The default is 0.05.\n * An interval in the margin is `same`, also when it is wholly below 1.\n */\n readonly margin?: number;\n /**\n * The noise cap on the A/A spread of the run, on a log scale. Above the cap, the outcome is `cannot decide`.\n * The cap also limits the bias of the A/A arm: an A/A median ratio out of `[exp(-noiseCap), exp(noiseCap)]` gives `cannot decide`.\n * The default is no cap.\n */\n readonly noiseCap?: number;\n /** The quantile of the A/A spread of the noise cap and of the pooled band. The default is 0.9. */\n readonly spreadLevel?: number;\n /**\n * The pooled band. It replaces the band of the A/A arm of the run in the rule `band` and in `comparison`.\n * The rule `difference` uses the larger of `margin` and the noise of the pooled band as its margin. The default is no pool.\n */\n readonly pool?: PoolOptions;\n}\n\n/** The noise cap of a verdict: the A/A spread of the run, the A/A median ratio of the run and the cap. */\nexport interface NoiseCheck {\n /** The A/A spread of the run, or undefined when the A/A arm has no cases. */\n readonly spread: number | undefined;\n readonly cap: number;\n /** This value is `true` when the spread is above the cap, or when the A/A arm has no cases. */\n readonly noisy: boolean;\n /** The median ratio of the A/A cases of the run, or undefined when the A/A arm has no cases. A value far from 1 shows a bias of the order or of the arm slots. */\n readonly aaMedian: number | undefined;\n /**\n * This value is `true` when the A/A median ratio of the run is out of `[exp(-cap), exp(cap)]`.\n * With a spread level of 0.5 or more, a biased run is also noisy. The check decides alone only below that level.\n */\n readonly biased: boolean;\n}\n\n/** A time verdict, with the facts that it uses. */\nexport interface TimeVerdict {\n readonly outcome: TimeOutcome;\n /** The reason of the outcome, in one sentence. */\n readonly reason: string;\n readonly cases: readonly CaseRatio[];\n readonly rule: VerdictRule;\n /**\n * The interval that the rule compares, or undefined when there are no candidate cases.\n * With too few A/A cases, it is the interval of the median ratio of the candidate.\n * For the rule `band`, it is the bootstrap interval of the median ratio of the candidate.\n * For the rule `difference`, it is the interval of the candidate median ratio over the A/A median ratio.\n */\n readonly interval: Interval | undefined;\n /** The band of the A/A arm, or undefined when the A/A arm has too few cases. */\n readonly band: Band | undefined;\n /**\n * The counts of the cases out of the band, or undefined without a band.\n * The comparison uses the value `1 + log(ratio)` of each case and the noise of the band, so its two sides are the ends of the band.\n */\n readonly comparison: Comparison | undefined;\n /** The facts of the pooled band. The verdict has this field only with the option `pool`. */\n readonly pool?: PoolFacts;\n /** The noise cap. The verdict has this field only with the option `noiseCap`. */\n readonly noise?: NoiseCheck;\n}\n\n/**\n * This function gives the time verdict of the candidate arm `b` against the baseline arm `a`.\n * - The rule `difference` gives `same` when the interval is in `[exp(-margin), exp(margin)]`. This test comes first, so\n * an interval in the margin and below 1 is `same`, not `faster`.\n * - Out of the margin, the rule `difference` gives `faster` when the whole interval is below 1, and `slower` when it is above 1.\n * With the margin 0, each outcome stays the same as in 0.1.2.\n * - The rule `band` gives `faster` below the band, `slower` above the band, and `same` in the band.\n * - Each other case is `cannot decide`, and so is an A/A arm with too few cases.\n * - With `noiseCap`, an A/A spread of the run above the cap gives `cannot decide`.\n * - With `noiseCap`, an A/A median ratio of the run out of `[exp(-noiseCap), exp(noiseCap)]` also gives `cannot decide`.\n * - With `pool`, the pooled band replaces the band of the A/A arm of the run. The run still needs `minimum` A/A cases.\n */\nexport function timeVerdict(candidate: readonly PairedTime[], aa: readonly PairedTime[], options: VerdictOptions = {}): TimeVerdict {\n const level = options.spreadLevel ?? 0.9;\n if (options.noiseCap !== undefined && !(options.noiseCap >= 0 && Number.isFinite(options.noiseCap))) {\n throw new RangeError(`timeVerdict: the noise cap is a finite number of 0 or more, not ${options.noiseCap}.`);\n }\n const pool = poolFor(options);\n let verdict = ruleVerdict(candidate, aa, options, pool?.band);\n if (pool !== undefined) verdict = { ...verdict, pool: pool.facts };\n if (options.noiseCap !== undefined) {\n const cap = options.noiseCap;\n const aaRatios = caseRatios(aa);\n const spread = aaRatios.length === 0 ? undefined : spreadOf(aaRatios, level);\n const aaMedian = aaRatios.length === 0 ? undefined : Math.exp(quantile(aaRatios.map((r) => Math.log(r.ratio)), 0.5));\n const biased = aaMedian !== undefined && Math.abs(Math.log(aaMedian)) > cap;\n const noise: NoiseCheck = { spread, cap, noisy: spread === undefined || spread > cap, aaMedian, biased };\n verdict = { ...verdict, noise };\n // The early outcomes (no candidate cases, too few A/A cases) keep their reason. Each other outcome gives way to the cap.\n if (noise.noisy && verdict.band !== undefined) {\n const why = spread === undefined ? \"The A/A arm of the run has no cases, so the noise cap has no spread.\" : `The A/A spread of the run is ${round(spread)}, above the noise cap ${cap}.`;\n const reason = `${why} Without the cap, the outcome is \"${verdict.outcome}\".`;\n verdict = { ...verdict, outcome: \"cannot decide\", reason };\n } else if (noise.biased && verdict.band !== undefined) {\n const reason = `The A/A median ratio of the run is ${round(aaMedian!)}, out of [${round(Math.exp(-cap))}, ${round(Math.exp(cap))}] of the noise cap ${cap}. Without the cap, the outcome is \"${verdict.outcome}\".`;\n verdict = { ...verdict, outcome: \"cannot decide\", reason };\n }\n }\n return verdict;\n}\n\n/** This function gives the pooled band and its facts of the options, or undefined without the option `pool`. */\nfunction poolFor(options: VerdictOptions): { band: Band; facts: PoolFacts } | undefined {\n return options.pool === undefined ? undefined : poolOf(options.pool, options.spreadLevel ?? 0.9);\n}\n\n/** This function gives the margin of the rule `difference`: the larger of `margin` and the noise of the pooled band. It refuses a margin below 0. */\nfunction marginOf(options: VerdictOptions, pooled: Band | undefined): number {\n const given = options.margin ?? 0.05;\n if (!(given >= 0)) throw new RangeError(`timeVerdict: the margin is 0 or more, not ${given}.`);\n return pooled === undefined ? given : Math.max(given, pooled.noise);\n}\n\n/**\n * This function gives the margin that the rule `difference` of `timeVerdict` uses with these options, on a log scale.\n * The margin is the larger of the option `margin` (default 0.05) and the noise of the pooled band. It uses the same code as the verdict.\n * The pooled band comes from the records of the option `pool`, not from the records of the run.\n * An interval in `[exp(-margin), exp(margin)]` has the outcome `same`. A page can draw that zone with this function.\n */\nexport function verdictMargin(options: VerdictOptions = {}): number {\n return marginOf(options, poolFor(options)?.band);\n}\n\n/** This function gives the outcome of the rule. A pooled band replaces the band of the A/A arm, and it widens the margin of the rule `difference`. */\nfunction ruleVerdict(candidate: readonly PairedTime[], aa: readonly PairedTime[], options: VerdictOptions, pooled: Band | undefined): TimeVerdict {\n const rule = options.rule ?? \"difference\";\n const cases = caseRatios(candidate);\n const aaRatios = caseRatios(aa);\n const minimum = options.minimum ?? 5;\n const none = { cases, rule, interval: undefined, band: undefined, comparison: undefined };\n if (cases.length === 0) return { ...none, outcome: \"cannot decide\", reason: \"The candidate has no cases.\" };\n if (aaRatios.length < minimum) {\n const interval = bootstrapMedian(cases.map((c) => c.ratio), options.bootstrap);\n return { ...none, interval, outcome: \"cannot decide\", reason: `The A/A arm has ${aaRatios.length} cases, and a band needs ${minimum} or more.` };\n }\n const band = pooled ?? aaBand(aa, options);\n const comparison = compareRatios(cases.map((c) => 1 + Math.log(c.ratio)), { better: \"lower\", noise: band.noise });\n const facts = { cases, rule, band, comparison };\n if (rule === \"difference\") {\n const margin = marginOf(options, pooled);\n const shown = pooled === undefined ? margin : round(margin);\n const logs = cases.map((c) => Math.log(c.ratio));\n const aaLogs = aaRatios.map((c) => Math.log(c.ratio));\n const d = bootstrapTwo(logs, aaLogs, (x, y) => median(x) - median(y), options.bootstrap);\n const interval: Interval = { ...d, estimate: Math.exp(d.estimate), low: Math.exp(d.low), high: Math.exp(d.high) };\n const span = `The interval of the candidate median over the A/A median is [${round(interval.low)}, ${round(interval.high)}].`;\n // The margin comes first: an interval in the margin is `same`, also when it is wholly below or above 1.\n if (d.low >= -margin && d.high <= margin) return { ...facts, interval, outcome: \"same\", reason: `${span} The interval is in the margin of ${shown}.` };\n if (interval.high < 1) return { ...facts, interval, outcome: \"faster\", reason: `${span} The interval is below 1.` };\n if (interval.low > 1) return { ...facts, interval, outcome: \"slower\", reason: `${span} The interval is above 1.` };\n return { ...facts, interval, outcome: \"cannot decide\", reason: `${span} The interval holds 1 and crosses the margin of ${shown}.` };\n }\n const interval = bootstrapMedian(cases.map((c) => c.ratio), options.bootstrap);\n const span = `The interval of the median ratio is [${round(interval.low)}, ${round(interval.high)}], and the A/A band is [${round(band.low)}, ${round(band.high)}].`;\n if (interval.high < band.low) return { ...facts, interval, outcome: \"faster\", reason: `${span} The interval is below the band.` };\n if (interval.low > band.high) return { ...facts, interval, outcome: \"slower\", reason: `${span} The interval is above the band.` };\n if (interval.low >= band.low && interval.high <= band.high) return { ...facts, interval, outcome: \"same\", reason: `${span} The interval is in the band.` };\n return { ...facts, interval, outcome: \"cannot decide\", reason: `${span} The interval crosses an end of the band.` };\n}\n\nfunction round(x: number): number {\n return Math.round(x * 10_000) / 10_000;\n}\n","/**\n * The limit verdict of a bench: is the ratio of each case at most a limit? For example, the claim \"the new code takes at most\n * 2 times the time of the old code\" needs it. The time verdict compares only with 1.\n */\nimport { medianInterval } from \"@mark1russell7/rigor-statistics\";\nimport { type CaseRatio, type PairedTime, caseRatios } from \"./paired.ts\";\nimport { type Band, type BandOptions, aaBand } from \"./verdict.ts\";\n\n/** The ratio of one case with the interval of its median over the rounds. */\nexport interface CaseInterval extends CaseRatio {\n /** The ends of the interval: `exp` of `medianInterval` over the values `log(b / a)` of the rounds. */\n readonly low: number;\n readonly high: number;\n /** The coverage of the interval. It is at least the level. */\n readonly coverage: number;\n}\n\n/**\n * This function gives the ratio of each case with a distribution-free interval of its median, in the order of\n * `caseRatios`. It needs enough rounds for the level: 6 rounds or more for the level 0.95.\n */\nexport function caseIntervals(records: readonly PairedTime[], level = 0.95): CaseInterval[] {\n const logs = new Map<string, number[]>();\n for (const r of records) {\n const list = logs.get(r.case) ?? [];\n list.push(Math.log(r.b / r.a));\n logs.set(r.case, list);\n }\n return caseRatios(records).map((c) => {\n const interval = medianInterval(logs.get(c.case)!, level);\n return { ...c, low: Math.exp(interval.low), high: Math.exp(interval.high), coverage: interval.coverage };\n });\n}\n\n/** The three outcomes of a limit verdict. */\nexport type LimitOutcome = \"within\" | \"beyond\" | \"cannot decide\";\n\n/** The options of a limit verdict. */\nexport interface LimitOptions extends BandOptions {\n /** The largest ratio `b / a` that the claim permits, for example 2. */\n readonly limit: number;\n /** The level of the interval of each case. The default is 0.95. */\n readonly caseLevel?: number;\n /**\n * The share of the cases that the claim needs `within`, above 0 and at most 1. The default 1 needs each case. With 0.95\n * and 20 cases, 1 case can be `beyond` or `cannot decide`. The option `timeTailQ` of a promotion record is this share.\n */\n readonly share?: number;\n}\n\n/** The verdict of one case against the limit. */\nexport interface CaseLimit extends CaseInterval {\n /** The high end of the interval of the case, times the high end of the A/A band. */\n readonly bound: number;\n /** The low end of the interval of the case, times the low end of the A/A band. */\n readonly floor: number;\n readonly outcome: LimitOutcome;\n}\n\n/** A limit verdict, with the facts that it uses. */\nexport interface LimitVerdict {\n readonly outcome: LimitOutcome;\n /** The reason of the outcome, in one sentence. */\n readonly reason: string;\n readonly limit: number;\n readonly cases: readonly CaseLimit[];\n /** The band of the A/A arm, or undefined when the A/A arm has too few cases. */\n readonly band: Band | undefined;\n /** The share of the option `share`. */\n readonly share: number;\n /** The number of cases that can be other than `within`: the floor of the number of cases times `1 - share`. */\n readonly allowed: number;\n}\n\n/**\n * This function gives the verdict of the claim \"the ratio `b / a` of each case is at most `limit`\". The A/A band widens\n * the interval of each case: the bound is the high end times the high end of the band.\n * - A case is `within` when its bound is at most the limit, and `beyond` when its floor is above the limit.\n * - The verdict is `within` when `allowed` cases or fewer are other than `within`. With the default share 1, `allowed` is 0.\n * - The verdict is `beyond` when more than `allowed` cases are `beyond`.\n * - Each other verdict is `cannot decide`, and so is an A/A arm with too few cases or a candidate with no cases.\n */\nexport function limitVerdict(candidate: readonly PairedTime[], aa: readonly PairedTime[], options: LimitOptions): LimitVerdict {\n const { limit } = options;\n if (!(limit > 0 && Number.isFinite(limit))) throw new RangeError(`limitVerdict: the limit is a finite number above 0, not ${limit}.`);\n const share = options.share ?? 1;\n if (!(share > 0 && share <= 1)) throw new RangeError(`limitVerdict: the share is above 0 and at most 1, not ${share}.`);\n const intervals = caseIntervals(candidate, options.caseLevel);\n const minimum = options.minimum ?? 5;\n // The small term keeps a product such as 10 * (1 - 0.9) = 0.9999999999999998 from a floor of 0.\n const allowed = Math.floor(intervals.length * (1 - share) + 1e-9);\n if (intervals.length === 0) return { outcome: \"cannot decide\", reason: \"The candidate has no cases.\", limit, cases: [], band: undefined, share, allowed };\n const aaCount = caseRatios(aa).length;\n if (aaCount < minimum) {\n const cases = intervals.map((c) => ({ ...c, bound: c.high, floor: c.low, outcome: \"cannot decide\" as const }));\n return { outcome: \"cannot decide\", reason: `The A/A arm has ${aaCount} cases, and a band needs ${minimum} or more.`, limit, cases, band: undefined, share, allowed };\n }\n const band = aaBand(aa, options);\n const cases = intervals.map((c): CaseLimit => {\n const bound = c.high * band.high;\n const floor = c.low * band.low;\n const outcome: LimitOutcome = bound <= limit ? \"within\" : floor > limit ? \"beyond\" : \"cannot decide\";\n return { ...c, bound, floor, outcome };\n });\n const facts = { limit, cases, band, share, allowed };\n const beyond = cases.filter((c) => c.outcome === \"beyond\");\n const others = cases.filter((c) => c.outcome !== \"within\");\n const permit = allowed === 0 ? \"\" : `, and the share ${share} permits ${allowed}`;\n if (beyond.length > allowed) {\n return { outcome: \"beyond\", reason: `${beyond.length} of ${cases.length} cases are above the limit ${limit}${permit}. The first is ${JSON.stringify(beyond[0]!.case)}.`, ...facts };\n }\n if (others.length <= allowed) {\n const inside = cases.filter((c) => c.outcome === \"within\");\n const top = (inside.length > 0 ? inside : cases).reduce((a, b) => (b.bound > a.bound ? b : a));\n const rest = others.length === 0 ? \"\" : ` ${others.length} of ${cases.length} cases are not within${permit}.`;\n return { outcome: \"within\", reason: `The largest bound of a case within is ${round(top.bound)} in the case ${JSON.stringify(top.case)}, and it is at most the limit ${limit}.${rest}`, ...facts };\n }\n const top = cases.reduce((a, b) => (b.bound > a.bound ? b : a));\n return { outcome: \"cannot decide\", reason: `${others.length} of ${cases.length} cases are not within${permit}. The bound of the case ${JSON.stringify(top.case)} is ${round(top.bound)}, above the limit ${limit}, and too few floors are above it.`, ...facts };\n}\n\nfunction round(x: number): number {\n return Math.round(x * 10_000) / 10_000;\n}\n","/**\n * The merge of the records of many jobs, and the pooled verdicts over them. Each job of a bench gives its own records.\n * A pooled verdict uses all jobs together, and the verdict of each job alone guards it.\n */\nimport { type LimitOptions, type LimitOutcome, type LimitVerdict, limitVerdict } from \"./limit.ts\";\nimport { type Arm, type PairedTime } from \"./paired.ts\";\nimport { type TimeOutcome, type TimeVerdict, type VerdictOptions, timeVerdict } from \"./verdict.ts\";\n\n/** The records of each case with a turned order, and the count of the records that the balance removed. */\nexport interface Balanced<T extends PairedTime> {\n readonly records: T[];\n /** The count of the removed records. It is 0 when each case has a turned order. */\n readonly trimmed: number;\n}\n\n/**\n * This function removes records until the two orders of each case differ in count by 1 or less.\n * It removes the records of the larger order with the highest rounds first. The other records keep their order.\n * A job that stopped early, or a missing job, can leave a case with 2 more rounds of one order. `caseRatios` refuses such a case.\n */\nexport function balanceOrders<T extends PairedTime>(records: readonly T[]): Balanced<T> {\n const byCase = new Map<string, Record<Arm, number[]>>();\n records.forEach((record, index) => {\n const orders = byCase.get(record.case) ?? { a: [], b: [] };\n orders[record.first === \"b\" ? \"b\" : \"a\"].push(index);\n byCase.set(record.case, orders);\n });\n const drop = new Set<number>();\n const highFirst = (x: number, y: number): number => records[y]!.round - records[x]!.round;\n for (const { a, b } of byCase.values()) {\n const [more, fewer] = a.length > b.length ? [a, b] : [b, a];\n const extra = more.length - fewer.length - 1;\n if (extra > 0) for (const index of more.toSorted(highFirst).slice(0, extra)) drop.add(index);\n }\n return { records: records.filter((_, index) => !drop.has(index)), trimmed: drop.size };\n}\n\n/** The records of one job: the candidate pair and the A/A pair. */\nexport interface JobRecords {\n /** The label of the job, for example the index of its CI job. A record with a field `job` has this label, or `poolRecords` refuses it. */\n readonly job: string;\n readonly candidate: readonly PairedTime[];\n readonly aa: readonly PairedTime[];\n /** The cases that the job skipped, as `freshRun` gives them. `poolRecords` removes each of these cases from all jobs. */\n readonly skipped?: readonly { readonly case: string }[];\n}\n\n/** The records of one job in a pool: the cases that no job skipped, balanced with `balanceOrders`. */\nexport interface PooledJob {\n readonly job: string;\n readonly candidate: PairedTime[];\n readonly aa: PairedTime[];\n}\n\n/** The pool of the jobs: the merged records of all jobs, and the records of each job alone. */\nexport interface PooledRecords {\n /** The merged candidate records of all jobs, balanced with `balanceOrders`. */\n readonly candidate: PairedTime[];\n /** The merged A/A records of all jobs, balanced with `balanceOrders`. */\n readonly aa: PairedTime[];\n /** The records of each job alone, in the order of the jobs. */\n readonly jobs: readonly PooledJob[];\n /** The count of the records that `balanceOrders` removed from the merged candidate and A/A records. */\n readonly trimmed: number;\n /** The cases that a job skipped, in sorted order. The pool has no record of these cases. */\n readonly dropped: string[];\n}\n\n/**\n * This function gives the pool of the jobs. `pooledVerdict` and `pooledLimitVerdict` use it.\n * - It refuses two jobs with one label, and a record with a different job label. It also refuses two jobs with a record of one case and one round.\n * - It removes each case that a job skipped from all jobs, so all jobs have the same cases.\n * - It merges the records of the jobs, and it balances the merged records and the records of each job with `balanceOrders`.\n */\nexport function poolRecords(jobs: readonly JobRecords[]): PooledRecords {\n return pool(jobs, \"poolRecords\");\n}\n\n/** The pool of `poolRecords`. Each error starts with the name `caller`. */\nfunction pool(jobs: readonly JobRecords[], caller: string): PooledRecords {\n const labels = new Set<string>();\n for (const { job } of jobs) {\n if (labels.has(job)) throw new RangeError(`${caller}: two jobs have the label ${JSON.stringify(job)}.`);\n labels.add(job);\n }\n for (const { job, candidate: c, aa: a } of jobs) {\n for (const r of [...c, ...a] as readonly (PairedTime & { readonly job?: unknown })[]) {\n if (r.job !== undefined && r.job !== job) throw new RangeError(`${caller}: a record of the job ${JSON.stringify(job)} has the job ${JSON.stringify(r.job)}.`);\n }\n }\n const dropped = [...new Set(jobs.flatMap((j) => (j.skipped ?? []).map((s) => s.case)))].sort();\n const gone = new Set(dropped);\n const keep = (records: readonly PairedTime[]): PairedTime[] => records.filter((r) => !gone.has(r.case));\n const kept = jobs.map((j) => ({ job: j.job, candidate: keep(j.candidate), aa: keep(j.aa) }));\n uniqueRounds(kept, \"candidate\", caller);\n uniqueRounds(kept, \"aa\", caller);\n const candidate = balanceOrders(kept.flatMap((j) => j.candidate));\n const aa = balanceOrders(kept.flatMap((j) => j.aa));\n const each = kept.map(({ job, candidate: c, aa: a }): PooledJob => ({ job, candidate: balanceOrders(c).records, aa: balanceOrders(a).records }));\n return { candidate: candidate.records, aa: aa.records, jobs: each, trimmed: candidate.trimmed + aa.trimmed, dropped };\n}\n\n/** This function refuses two jobs with a record of one case and one round in one pair. */\nfunction uniqueRounds(jobs: readonly PooledJob[], pair: \"candidate\" | \"aa\", caller: string): void {\n const seen = new Map<string, string>();\n for (const { job, [pair]: records } of jobs) {\n for (const r of records) {\n const key = `${r.case}\\u0000${r.round}`;\n const other = seen.get(key);\n if (other !== undefined && other !== job) {\n throw new RangeError(\n `${caller}: the jobs ${JSON.stringify(other)} and ${JSON.stringify(job)} both have the round ${r.round} of the case ${JSON.stringify(r.case)} in the ${pair} pair. Set roundOffset of each job to job * rounds.`,\n );\n }\n seen.set(key, job);\n }\n }\n}\n\n/** The guard of a pooled verdict: the outcome, the opposed jobs and the reason. */\ninterface Guarded<O extends string> {\n readonly outcome: O | \"cannot decide\";\n readonly opposed: string[];\n readonly reason: string;\n}\n\n/**\n * This function applies the guard of the jobs to a pooled verdict. A job whose outcome is `opposite` of the pooled outcome\n * makes the outcome `cannot decide`. Each other job does not change the outcome.\n */\nfunction guard<O extends string>(\n pooled: { readonly outcome: O; readonly reason: string },\n jobs: readonly { readonly job: string; readonly verdict: { readonly outcome: O } }[],\n opposite: Partial<Record<O, O>>,\n): Guarded<O> {\n const against = opposite[pooled.outcome];\n const opposed = against === undefined ? [] : jobs.filter((j) => j.verdict.outcome === against).map((j) => j.job);\n if (opposed.length === 0) return { outcome: pooled.outcome, opposed, reason: pooled.reason };\n const names = opposed.map((j) => JSON.stringify(j)).join(\", \");\n const reason = `${pooled.reason} The pooled outcome is \"${pooled.outcome}\", but the jobs ${names} give \"${against}\". Thus the outcome is \"cannot decide\".`;\n return { outcome: \"cannot decide\", opposed, reason };\n}\n\n/** The verdict of one job alone. */\nexport interface JobVerdict {\n readonly job: string;\n readonly verdict: TimeVerdict;\n}\n\n/** The pooled verdict over the jobs, with the verdict of each job alone. */\nexport interface PooledVerdict {\n /** The outcome of the pooled verdict, or `cannot decide` when a job decides the opposite direction. */\n readonly outcome: TimeOutcome;\n /** The verdict of the merged and balanced records of all jobs. */\n readonly pooled: TimeVerdict;\n /** The verdict of each job alone, with the options of the pooled verdict. */\n readonly jobs: readonly JobVerdict[];\n /** The jobs whose own outcome is the opposite direction of the pooled outcome. */\n readonly opposed: string[];\n /** The count of the records that `balanceOrders` removed from the merged candidate and A/A records. */\n readonly trimmed: number;\n /** The cases that a job skipped, in sorted order. The verdicts use no record of these cases. */\n readonly dropped: string[];\n /** The reason of the pooled verdict, and the opposed jobs. */\n readonly reason: string;\n}\n\nconst opposite: Partial<Record<TimeOutcome, TimeOutcome>> = { faster: \"slower\", slower: \"faster\" };\n\n/**\n * This function gives the time verdict over the records of all jobs.\n * - It makes the pool of the jobs with `poolRecords`, and it gives the time verdict of the merged records.\n * - The verdict of each job alone uses the same options. A job with `cannot decide` or `same` does not change the outcome.\n * - A job that decides the opposite direction of the pooled outcome makes the outcome `cannot decide`.\n */\nexport function pooledVerdict(jobs: readonly JobRecords[], options: VerdictOptions = {}): PooledVerdict {\n const { candidate, aa, jobs: each, trimmed, dropped } = pool(jobs, \"pooledVerdict\");\n const pooled = timeVerdict(candidate, aa, options);\n const verdicts = each.map(({ job, candidate: c, aa: a }): JobVerdict => ({ job, verdict: timeVerdict(c, a, options) }));\n const { outcome, opposed, reason } = guard(pooled, verdicts, opposite);\n return { outcome, pooled, jobs: verdicts, opposed, trimmed, dropped, reason };\n}\n\n/** The limit verdict of one job alone. */\nexport interface JobLimitVerdict {\n readonly job: string;\n readonly verdict: LimitVerdict;\n}\n\n/** The pooled limit verdict over the jobs, with the limit verdict of each job alone. */\nexport interface PooledLimitVerdict {\n /** The outcome of the pooled limit verdict, or `cannot decide` when a job gives the opposite outcome. */\n readonly outcome: LimitOutcome;\n /** The limit verdict of the merged and balanced records of all jobs. */\n readonly pooled: LimitVerdict;\n /** The limit verdict of each job alone, with the options of the pooled verdict. */\n readonly jobs: readonly JobLimitVerdict[];\n /** The jobs whose own outcome is the opposite of the pooled outcome: `beyond` against `within`, or the reverse. */\n readonly opposed: string[];\n /** The count of the records that `balanceOrders` removed from the merged candidate and A/A records. */\n readonly trimmed: number;\n /** The cases that a job skipped, in sorted order. The verdicts use no record of these cases. */\n readonly dropped: string[];\n /** The reason of the pooled limit verdict, and the opposed jobs. */\n readonly reason: string;\n}\n\nconst limitOpposite: Partial<Record<LimitOutcome, LimitOutcome>> = { within: \"beyond\", beyond: \"within\" };\n\n/**\n * This function gives the limit verdict over the records of all jobs, for example for a speed gate on limits over a CI matrix.\n * - It makes the pool of the jobs with `poolRecords`, and it gives the limit verdict of the merged records.\n * - The verdict of each job alone uses the same options. A job with `cannot decide` does not change the outcome.\n * - A job with `beyond` against a pooled `within`, or the reverse, makes the outcome `cannot decide`.\n */\nexport function pooledLimitVerdict(jobs: readonly JobRecords[], options: LimitOptions): PooledLimitVerdict {\n const { candidate, aa, jobs: each, trimmed, dropped } = pool(jobs, \"pooledLimitVerdict\");\n const pooled = limitVerdict(candidate, aa, options);\n const verdicts = each.map(({ job, candidate: c, aa: a }): JobLimitVerdict => ({ job, verdict: limitVerdict(c, a, options) }));\n const { outcome, opposed, reason } = guard(pooled, verdicts, limitOpposite);\n return { outcome, pooled, jobs: verdicts, opposed, trimmed, dropped, reason };\n}\n\n/** The pairs of a run: the records of each pair, by the id of the pair. */\nexport interface RunPairs {\n readonly pairs: Readonly<Record<string, readonly PairedTime[]>>;\n}\n\n/**\n * This function gives the verdict of each candidate pair of a run against its A/A pair `aaPair`.\n * It balances the records of each pair with `balanceOrders` first. It refuses an `aaPair` that the run does not have.\n */\nexport function armVerdicts(run: RunPairs, aaPair: string, options: VerdictOptions = {}): Record<string, TimeVerdict> {\n const aaRecords = run.pairs[aaPair];\n if (aaRecords === undefined) throw new RangeError(`armVerdicts: the run has no pair ${JSON.stringify(aaPair)}.`);\n const aa = balanceOrders(aaRecords).records;\n const out: Record<string, TimeVerdict> = {};\n for (const [pair, records] of Object.entries(run.pairs)) {\n if (pair !== aaPair) out[pair] = timeVerdict(balanceOrders(records).records, aa, options);\n }\n return out;\n}\n","/**\n * The power test of a time verdict. It draws seeded benches with a known speedup and counts the verdicts that find it.\n * It also draws benches with equal arms and counts the false verdicts.\n */\nimport { random } from \"@mark1russell7/rigor-generators\";\nimport { firstArm, type PairedTime } from \"./paired.ts\";\nimport { type TimeOutcome, type VerdictOptions, timeVerdict, verdictMargin } from \"./verdict.ts\";\n\n/** The options of a power test. */\nexport interface PowerOptions {\n /** The count of the cases of the candidate and of the A/A arm. */\n readonly cases: number;\n /** The count of the rounds of each case. The default is 5. */\n readonly rounds?: number;\n /** The true ratio of the candidate time to the baseline time, for example 0.93 for a speedup of 7%. */\n readonly ratio: number;\n /** The standard deviation of the log time of one arm in one round. The default is 0.1. */\n readonly sigma?: number;\n /** The count of the seeded benches. The default is 200. */\n readonly trials?: number;\n /** The seed of the draws. The default is 1. */\n readonly seed?: number | string;\n /** The options of the verdict of each bench. */\n readonly verdict?: VerdictOptions;\n}\n\n/** The result of a power test: the share of each outcome over the trials. */\nexport interface Power {\n readonly trials: number;\n readonly outcomes: Readonly<Record<TimeOutcome, number>>;\n /**\n * The share of the trials whose outcome is the true one. For the rule `difference`, a ratio in the margin of the verdict has the true outcome `same`.\n * That margin is the larger of `margin` and the noise of the pooled band. The pool is the same in each trial, so each trial has the same margin.\n * Out of that margin, and for the rule `band`, the true outcome is `faster` below 1, `slower` above 1 and `same` at 1.\n */\n readonly power: number;\n}\n\n/**\n * This function draws `trials` benches and gives the share of each verdict. Each case has its own log scale.\n * Each arm of each round adds a normal noise of `sigma` to the log time.\n */\nexport function verdictPower(options: PowerOptions): Power {\n const rounds = options.rounds ?? 5;\n const sigma = options.sigma ?? 0.1;\n const trials = options.trials ?? 200;\n if (!Number.isSafeInteger(options.cases) || options.cases < 1) throw new RangeError(`verdictPower: cases is a whole number of 1 or more, not ${options.cases}.`);\n if (!(options.ratio > 0 && Number.isFinite(options.ratio))) throw new RangeError(`verdictPower: the ratio is a finite number above 0, not ${options.ratio}.`);\n const r = random(options.seed ?? 1);\n const bench = (ratio: number, prefix: string): PairedTime[] => {\n const out: PairedTime[] = [];\n for (let c = 0; c < options.cases; c++) {\n const scale = 10 * Math.exp(r.normal());\n for (let round = 0; round < rounds; round++) {\n const a = scale * Math.exp(r.normal(0, sigma));\n const b = scale * ratio * Math.exp(r.normal(0, sigma));\n out.push({ case: `${prefix}${c}`, round, first: firstArm(round, c), a, b });\n }\n }\n return out;\n };\n const truth = trueOutcome(options.ratio, options.verdict);\n const counts: Record<TimeOutcome, number> = { faster: 0, slower: 0, same: 0, \"cannot decide\": 0 };\n for (let t = 0; t < trials; t++) {\n const aa = bench(1, \"aa\");\n const candidate = bench(options.ratio, \"c\");\n counts[timeVerdict(candidate, aa, options.verdict).outcome]++;\n }\n const outcomes = Object.fromEntries(Object.entries(counts).map(([k, n]) => [k, n / trials])) as Record<TimeOutcome, number>;\n return { trials, outcomes, power: outcomes[truth] };\n}\n\n/** This function gives the true outcome of a ratio. The margin of the rule `difference` comes first, as in `timeVerdict`. */\nfunction trueOutcome(ratio: number, verdict: VerdictOptions = {}): TimeOutcome {\n if ((verdict.rule ?? \"difference\") === \"difference\" && Math.abs(Math.log(ratio)) <= verdictMargin(verdict)) return \"same\";\n return ratio < 1 ? \"faster\" : ratio > 1 ? \"slower\" : \"same\";\n}\n","/**\n * The timed rounds of one case in one process. The two arms first run for a warm-up time. Then the count of calls of\n * one batch grows until a batch of arm `a` takes the target time. Each round times one batch of each arm, in the order\n * of `firstArm`. Start this function in a fresh process for each case.\n */\nimport { type Arm, type PairedTime, firstArm } from \"./paired.ts\";\n\n/** The options of the timed rounds of one case. */\nexport interface RoundsOptions {\n /** The name of the case. */\n readonly case: string;\n /** The count of the rounds. */\n readonly rounds: number;\n /** The offset of `firstArm`: give the index of the case, so half of the cases start with each arm. The default is 0. */\n readonly offset?: number;\n /** The least time in milliseconds of one batch of arm `a`. The default is 10. */\n readonly targetMs?: number;\n /** The time in milliseconds of the warm-up of the two arms. The default is 1000. */\n readonly warmMs?: number;\n /** The clock in milliseconds. The default is `performance.now` of the global `performance` of Node and of each browser. */\n readonly now?: () => number;\n}\n\n/** The result of the timed rounds of one case. */\nexport interface Rounds {\n readonly records: PairedTime[];\n /** The count of calls of each arm in one batch. */\n readonly count: number;\n /** The sum of the numbers that the arms gave. The engine cannot remove the work of a call, because this sum uses it. */\n readonly sink: number;\n}\n\n/**\n * This function times the arms `a` and `b` of one case, and gives one `PairedTime` record for each round. The time of\n * a record is the time of one batch, in milliseconds. Each call of an arm gives a number, and the sum of these numbers\n * keeps the work.\n */\nexport function timeRounds(arms: Readonly<Record<Arm, () => number>>, options: RoundsOptions): Rounds {\n const { rounds } = options;\n const offset = options.offset ?? 0;\n const targetMs = options.targetMs ?? 10;\n const warmMs = options.warmMs ?? 1000;\n const now = options.now ?? (() => performance.now());\n if (!Number.isSafeInteger(rounds) || rounds < 1) throw new RangeError(`timeRounds: the rounds are a whole number of 1 or more, not ${rounds}.`);\n if (!Number.isSafeInteger(offset)) throw new RangeError(`timeRounds: the offset is a whole number, not ${offset}.`);\n if (!(targetMs > 0) || !(warmMs >= 0)) throw new RangeError(\"timeRounds: the target time is above 0, and the warm-up time is 0 or more.\");\n let sink = 0;\n const batch = (arm: Arm, count: number): number => {\n const run = arms[arm];\n const start = now();\n for (let i = 0; i < count; i++) sink += run();\n return now() - start;\n };\n let count = 1;\n const warmUntil = now() + warmMs;\n while (now() < warmUntil) {\n if (batch(\"a\", count) < targetMs / 4) count *= 2;\n batch(\"b\", count);\n }\n while (batch(\"a\", count) < targetMs) count *= 2;\n const records: PairedTime[] = [];\n for (let round = 0; round < rounds; round++) {\n const first = firstArm(round, offset);\n const second: Arm = first === \"a\" ? \"b\" : \"a\";\n const times = { [first]: batch(first, count), [second]: batch(second, count) } as Record<Arm, number>;\n records.push({ case: options.case, round, first, a: times.a, b: times.b });\n }\n return { records, count, sink };\n}\n"],"mappings":";;;;;;;;;;AA+DA,SAAS,cAAc,MAAc,QAAuD;CAC1F,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,sBAAM,IAAI,IAAsB;CACtC,KAAK,MAAM,KAAK,QAAQ;EACtB,IAAI,EAAE,OAAO,SAAS,EAAE,KAAK,KAAK,EAAE,SAAS,IAAI,MAAM,IAAI,WAAW,+BAA+B,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,gCAAgC,EAAE,MAAM,EAAE;EACjL,MAAM,MAAM,KAAK,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;EAC5C,IAAI,KAAK,IAAI,GAAG,GAAG,MAAM,IAAI,WAAW,4BAA4B,EAAE,MAAM,MAAM,KAAK,UAAU,EAAE,IAAI,EAAE,kBAAkB,KAAK,EAAE;EAClI,KAAK,IAAI,GAAG;EACZ,IAAI,IAAI,EAAE,MAAM,CAAC,GAAI,IAAI,IAAI,EAAE,IAAI,KAAK,CAAC,GAAI,EAAE,KAAK,CAAC;CACvD;CACA,OAAO;AACT;;AAGA,SAAS,WAAW,MAAc,QAA2B,UAA6B,SAAwB,OAA2B;CAC3I,MAAM,EAAE,OAAO,kBAAkB;CACjC,MAAM,WAAW,eAAe,QAAQ,KAAK;CAC7C,MAAM,SAAS,OAAO,MAAM;CAC5B,MAAM,WAAW,SAAS,SAAS,IAAI,OAAO,QAAQ,IAAI,KAAA;CAC1D,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,cAAc,YAAY,IAAI;CAClD,IAAI,CAAC,OAAO,cAAc,MAAM,KAAK,SAAS,GAAG,MAAM,IAAI,WAAW,+DAA+D,OAAO,EAAE;CAC9I,IAAI,CAAC,OAAO,cAAc,MAAM,GAAG,MAAM,IAAI,WAAW,iDAAiD,OAAO,EAAE;CAClH,IAAI,EAAE,WAAW,MAAM,EAAE,UAAU,IAAI,MAAM,IAAI,WAAW,4EAA4E;CACxI,IAAI,OAAO;CACX,MAAM,SAAS,KAAU,UAA0B;EACjD,MAAM,MAAM,KAAK;EACjB,MAAM,QAAQ,IAAI;EAClB,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,KAAK,QAAQ,IAAI;EAC5C,OAAO,IAAI,IAAI;CACjB;CACA,IAAI,QAAQ;CACZ,MAAM,YAAY,IAAI,IAAI;CAC1B,OAAO,IAAI,IAAI,WAAW;EACxB,IAAI,MAAM,KAAK,KAAK,IAAI,WAAW,GAAG,SAAS;EAC/C,MAAM,KAAK,KAAK;CAClB;CACA,OAAO,MAAM,KAAK,KAAK,IAAI,UAAU,SAAS;CAC9C,MAAM,UAAwB,CAAC;CAC/B,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,SAAS;EAC3C,MAAM,QAAQ,SAAS,OAAO,MAAM;EACpC,MAAM,SAAc,UAAU,MAAM,MAAM;EAC1C,MAAM,QAAQ;IAAG,QAAQ,MAAM,OAAO,KAAK;IAAI,SAAS,MAAM,QAAQ,KAAK;EAAE;EAC7E,QAAQ,KAAK;GAAE,MAAM,QAAQ;GAAM;GAAO;GAAO,GAAG,MAAM;GAAG,GAAG,MAAM;EAAE,CAAC;CAC3E;CACA,OAAO;EAAE;EAAS;EAAO;CAAK;AAChC"}
|
package/build/supervise.d.ts
CHANGED
|
@@ -12,6 +12,11 @@ export interface SupervisedCase {
|
|
|
12
12
|
* A case with stages `pack` and `route` can thus count against a router, or against a packer, and not against both.
|
|
13
13
|
*/
|
|
14
14
|
readonly groups?: Readonly<Record<string, string>>;
|
|
15
|
+
/**
|
|
16
|
+
* The place of the case in its groups, for example its input size. The default is 0.
|
|
17
|
+
* Overruns count for each group and rank. They stop the cases of that group at that rank and above, and a smaller rank goes on.
|
|
18
|
+
*/
|
|
19
|
+
readonly rank?: number;
|
|
15
20
|
}
|
|
16
21
|
/** The end of a case that did not finish: an overrun, which is measured, or a skip, which is not. */
|
|
17
22
|
export type SupervisedEnd = {
|
|
@@ -80,7 +85,9 @@ export declare function caseProgress(file: string, now?: () => number): CaseProg
|
|
|
80
85
|
* This function runs the cases and holds each case to its budget.
|
|
81
86
|
*
|
|
82
87
|
* - A stage over its budget stops the child, and `onEnd` gets `over-budget`. The next child runs the cases that are left.
|
|
83
|
-
* - After `overruns` overruns in one group, each other case of the group ends as `not-run
|
|
88
|
+
* - After `overruns` overruns in one group at one rank, each other case of the group at that rank or above ends as `not-run`.
|
|
89
|
+
* The end has the ids of those overruns.
|
|
90
|
+
* - A case of a smaller rank goes on, and an overrun at another rank does not count. With no ranks, all cases of a group have one rank.
|
|
84
91
|
* - A case in `done` or `earlier` does not run. A case that ended, or that has an end from `onEnd`, does not run again.
|
|
85
92
|
* - An `over-budget` end of `earlier` counts as an overrun of this run. `onEnd` does not get the end again.
|
|
86
93
|
* - A child that ends without a stop ends the run. Its exit code is the code of the result.
|
package/build/supervise.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervise.d.ts","names":[],"sources":["../src/supervise.ts"],"mappings":";qBAYa;;qBAGA;;iBAGI;WACN;;WAEA;;;;;WAKA,SAAS,SAAS;;;
|
|
1
|
+
{"version":3,"file":"supervise.d.ts","names":[],"sources":["../src/supervise.ts"],"mappings":";qBAYa;;qBAGA;;iBAGI;WACN;;WAEA;;;;;WAKA,SAAS,SAAS;;;;;WAKlB;;;YAIC;WACG;WAA8B;WAAqB;WAA2B;;WAC9E;WAA0B;WAAqB;WAA2B;WAAwB;;;iBAGhG;;EAEf;;WAES,QAAQ;;;iBAIF;;WAEN,gBAAgB;;WAEhB,OAAO;;;;;WAKP,mBAAmB;;WAEnB;;WAEA,QAAQ,4BAA4B;;WAEpC,QAAQ,KAAK;;WAEb;;WAEA;;WAEA;;;iBAIM;;WAEN;;WAEA;WACA,eAAe;;WAEf;;;iBAIM;;EAEf,MAAM,YAAY;;EAElB,IAAI;;;wBAWU,aAAa,cAAc,qBAA+B;;;;;;;;;;;;;wBAgCpD,eAAe,SAAS,mBAAmB,QAAQ;;wBAwGzD,uBAAuB,yBAAyB;WAAoB;WAAuB,MAAM,OAAO;IAAoB"}
|
package/build/supervise.js
CHANGED
|
@@ -43,7 +43,9 @@ function progressReader(file) {
|
|
|
43
43
|
* This function runs the cases and holds each case to its budget.
|
|
44
44
|
*
|
|
45
45
|
* - A stage over its budget stops the child, and `onEnd` gets `over-budget`. The next child runs the cases that are left.
|
|
46
|
-
* - After `overruns` overruns in one group, each other case of the group ends as `not-run
|
|
46
|
+
* - After `overruns` overruns in one group at one rank, each other case of the group at that rank or above ends as `not-run`.
|
|
47
|
+
* The end has the ids of those overruns.
|
|
48
|
+
* - A case of a smaller rank goes on, and an overrun at another rank does not count. With no ranks, all cases of a group have one rank.
|
|
47
49
|
* - A case in `done` or `earlier` does not run. A case that ended, or that has an end from `onEnd`, does not run again.
|
|
48
50
|
* - An `over-budget` end of `earlier` counts as an overrun of this run. `onEnd` does not get the end again.
|
|
49
51
|
* - A child that ends without a stop ends the run. Its exit code is the code of the result.
|
|
@@ -54,6 +56,7 @@ async function superviseCases(options) {
|
|
|
54
56
|
const limit = options.overruns ?? 2;
|
|
55
57
|
const pollMs = options.pollMs ?? 1e3;
|
|
56
58
|
const byId = new Map(cases.map((c) => [c.id, c]));
|
|
59
|
+
for (const c of cases) if (c.rank !== void 0 && !Number.isFinite(c.rank)) throw new RangeError(`The case "${c.id}" has the rank ${c.rank}. A rank must be a finite number.`);
|
|
57
60
|
const finished = new Set(options.done ?? []);
|
|
58
61
|
const groupOverruns = /* @__PURE__ */ new Map();
|
|
59
62
|
const ends = [];
|
|
@@ -64,12 +67,16 @@ async function superviseCases(options) {
|
|
|
64
67
|
onEnd(end);
|
|
65
68
|
};
|
|
66
69
|
const countOverrun = (id, stage) => {
|
|
67
|
-
const
|
|
70
|
+
const overrun = byId.get(id);
|
|
71
|
+
const group = overrun?.groups?.[stage];
|
|
68
72
|
if (group === void 0) return;
|
|
69
|
-
const
|
|
70
|
-
groupOverruns.
|
|
73
|
+
const rank = overrun?.rank ?? 0;
|
|
74
|
+
const ranks = groupOverruns.get(group) ?? /* @__PURE__ */ new Map();
|
|
75
|
+
const ids = [...ranks.get(rank) ?? [], id];
|
|
76
|
+
ranks.set(rank, ids);
|
|
77
|
+
groupOverruns.set(group, ranks);
|
|
71
78
|
if (ids.length < limit) return;
|
|
72
|
-
for (const c of cases) if (!finished.has(c.id) && Object.values(c.groups ?? {}).includes(group)) report({
|
|
79
|
+
for (const c of cases) if (!finished.has(c.id) && (c.rank ?? 0) >= rank && Object.values(c.groups ?? {}).includes(group)) report({
|
|
73
80
|
kind: "not-run",
|
|
74
81
|
id: c.id,
|
|
75
82
|
budgetMs: c.budgetMs,
|
package/build/supervise.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervise.js","names":[],"sources":["../src/supervise.ts"],"sourcesContent":["/**\n * The runner of cases with a time budget. A case runs in a child process, so a hard stop works on code that does not return.\n * One child runs each case that is left. The child writes the start and the end of each case to a progress file.\n * When a case passes its budget, the supervisor stops the child, reports the case, and starts a new child on the cases that are left.\n * Only an overrun costs a new child, so the times of the other cases do not change.\n */\n\nimport { spawn } from \"node:child_process\";\nimport { appendFileSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { stopTree } from \"./tree.ts\";\n\n/** The count of overruns in one group, after which the other cases of the group do not run. */\nexport const DEFAULT_OVERRUNS = 2;\n\n/** The time between two reads of the progress file, in milliseconds. */\nexport const DEFAULT_POLL_MS = 1000;\n\n/** One case of a supervised run. */\nexport interface SupervisedCase {\n readonly id: string;\n /** The time budget of each stage of the case, in milliseconds. */\n readonly budgetMs: number;\n /**\n * The group of each stage of the case. An overrun in a stage counts for the group of that stage only.\n * A case with stages `pack` and `route` can thus count against a router, or against a packer, and not against both.\n */\n readonly groups?: Readonly<Record<string, string>>;\n}\n\n/** The end of a case that did not finish: an overrun, which is measured, or a skip, which is not. */\nexport type SupervisedEnd =\n | { readonly kind: \"over-budget\"; readonly id: string; readonly budgetMs: number; readonly stage: string }\n | { readonly kind: \"not-run\"; readonly id: string; readonly budgetMs: number; readonly group: string; readonly because: readonly string[] };\n\n/** One running child. */\nexport interface SupervisedChild {\n /** This function stops the child and its tree at once. */\n stop(): void;\n /** The exit code of the child, or `null` when a signal stopped it. */\n readonly exited: Promise<number | null>;\n}\n\n/** The options of `superviseCases`. */\nexport interface SuperviseOptions {\n /** The cases, in the order of the run. */\n readonly cases: readonly SupervisedCase[];\n /** The ids of the cases of an earlier run. These cases do not run. */\n readonly done?: ReadonlySet<string>;\n /**\n * The ends of an earlier run of these cases, in their order. These cases do not run, and an `over-budget` end needs its case in `cases`.\n * Each `over-budget` end counts for its group, so a stop and a resume give the same ends as a run with no stop.\n */\n readonly earlier?: readonly SupervisedEnd[];\n /** The file that the child writes with `caseProgress`. The supervisor makes it empty at the start. */\n readonly progressFile: string;\n /** This function starts a child on the ids that are left. */\n readonly start: (left: readonly string[]) => SupervisedChild;\n /** This function is the callback for the record of each case that did not finish. */\n readonly onEnd: (end: SupervisedEnd) => void;\n /** The default is `DEFAULT_OVERRUNS`. */\n readonly overruns?: number;\n /** The default is `DEFAULT_POLL_MS`. */\n readonly pollMs?: number;\n /** The clock of the supervisor. It is the clock of `caseProgress`. */\n readonly now?: () => number;\n}\n\n/** The result of `superviseCases`. */\nexport interface SuperviseResult {\n /** The exit code of the last child, or `null` when no child ran or a signal stopped the last child. */\n readonly code: number | null;\n /** The count of the children. */\n readonly starts: number;\n readonly ends: readonly SupervisedEnd[];\n /** The ids that have no result, because the last child ended before them. */\n readonly left: readonly string[];\n}\n\n/** The writer of a progress file, for the child. */\nexport interface CaseProgress {\n /** This function tells that a stage of a case starts. Each stage has its own budget. */\n start(id: string, stage?: string): void;\n /** This function tells that a case ended. Call it after the result of the case is on the disk. */\n end(id: string): void;\n}\n\ninterface ProgressEvent {\n readonly event: \"start\" | \"end\";\n readonly id: string;\n readonly stage?: string;\n readonly at?: number;\n}\n\n/** This function gives the writer of a progress file. Each write is synchronous, so it works in a loop that does not yield. */\nexport function caseProgress(file: string, now: () => number = Date.now): CaseProgress {\n const write = (event: ProgressEvent): void => appendFileSync(file, `${JSON.stringify(event)}\\n`);\n return {\n start: (id, stage = \"\") => write({ event: \"start\", id, stage, at: now() }),\n end: (id) => write({ event: \"end\", id }),\n };\n}\n\n/** The reader of a progress file: each call gives the events of the lines that are whole and were not read. */\nfunction progressReader(file: string): () => ProgressEvent[] {\n let read = 0;\n return () => {\n const text = readFileSync(file, \"utf8\");\n const whole = text.slice(0, text.lastIndexOf(\"\\n\") + 1);\n const lines = whole.slice(read).split(\"\\n\").filter((line) => line !== \"\");\n read = whole.length;\n return lines.map((line) => JSON.parse(line) as ProgressEvent);\n };\n}\n\n/**\n * This function runs the cases and holds each case to its budget.\n *\n * - A stage over its budget stops the child, and `onEnd` gets `over-budget`. The next child runs the cases that are left.\n * - After `overruns` overruns in one group, each other case of the group ends as `not-run`, with the ids of those overruns.\n * - A case in `done` or `earlier` does not run. A case that ended, or that has an end from `onEnd`, does not run again.\n * - An `over-budget` end of `earlier` counts as an overrun of this run. `onEnd` does not get the end again.\n * - A child that ends without a stop ends the run. Its exit code is the code of the result.\n * - A line of the progress file that is not JSON stops the child, and this function then throws the error.\n */\nexport async function superviseCases(options: SuperviseOptions): Promise<SuperviseResult> {\n const { cases, progressFile, start, onEnd, now = Date.now } = options;\n const limit = options.overruns ?? DEFAULT_OVERRUNS;\n const pollMs = options.pollMs ?? DEFAULT_POLL_MS;\n const byId = new Map(cases.map((c) => [c.id, c]));\n const finished = new Set(options.done ?? []);\n const groupOverruns = new Map<string, string[]>();\n const ends: SupervisedEnd[] = [];\n const left = (): string[] => cases.filter((c) => !finished.has(c.id)).map((c) => c.id);\n const report = (end: SupervisedEnd): void => {\n finished.add(end.id);\n ends.push(end);\n onEnd(end);\n };\n const countOverrun = (id: string, stage: string): void => {\n const group = byId.get(id)?.groups?.[stage];\n if (group === undefined) return;\n const ids = [...(groupOverruns.get(group) ?? []), id];\n groupOverruns.set(group, ids);\n if (ids.length < limit) return;\n for (const c of cases) {\n if (!finished.has(c.id) && Object.values(c.groups ?? {}).includes(group)) report({ kind: \"not-run\", id: c.id, budgetMs: c.budgetMs, group, because: ids.slice(0, limit) });\n }\n };\n\n const earlier = options.earlier ?? [];\n for (const end of earlier) {\n if (end.kind === \"over-budget\" && !byId.has(end.id)) throw new RangeError(`The case \"${end.id}\" of the option earlier is not in the option cases.`);\n finished.add(end.id);\n }\n for (const end of earlier) {\n if (end.kind === \"over-budget\") countOverrun(end.id, end.stage);\n }\n\n writeFileSync(progressFile, \"\");\n const readEvents = progressReader(progressFile);\n const state: { running?: { readonly id: string; readonly stage: string; readonly at: number } | undefined; exit?: { readonly code: number | null } | undefined } = {};\n const update = (): void => {\n for (const event of readEvents()) {\n if (event.event === \"start\") {\n state.running = { id: event.id, stage: event.stage ?? \"\", at: event.at ?? now() };\n } else {\n finished.add(event.id);\n if (state.running?.id === event.id) state.running = undefined;\n }\n }\n };\n\n // A function makes this reset, so that the checks of the loop see the declared types of the state.\n const forgetChild = (): void => {\n state.running = undefined;\n state.exit = undefined;\n };\n\n let starts = 0;\n let code: number | null = null;\n while (left().length > 0) {\n forgetChild();\n starts += 1;\n const child = start(left());\n const exited = child.exited.then((value) => {\n state.exit = { code: value };\n });\n let over: { readonly id: string; readonly stage: string; readonly budgetMs: number } | undefined;\n while (state.exit === undefined && over === undefined) {\n let timer: ReturnType<typeof setTimeout> | undefined;\n await Promise.race([exited, new Promise((resolve) => (timer = setTimeout(resolve, pollMs)))]);\n clearTimeout(timer);\n try {\n update();\n } catch (error) {\n // A progress file that cannot be read cannot hold the child to its budget, so the child must not outlive the supervisor.\n child.stop();\n await exited;\n throw error;\n }\n const current = state.running;\n const budgetMs = current === undefined ? undefined : byId.get(current.id)?.budgetMs;\n if (state.exit === undefined && current !== undefined && budgetMs !== undefined && now() - current.at > budgetMs) over = { id: current.id, stage: current.stage, budgetMs };\n }\n if (over === undefined) {\n code = state.exit?.code ?? null;\n break;\n }\n child.stop();\n await exited;\n code = null;\n update();\n // The case can end between the read and the stop. Then its result is on the disk, and it has no overrun.\n if (finished.has(over.id)) continue;\n report({ kind: \"over-budget\", ...over });\n countOverrun(over.id, over.stage);\n }\n return { code, starts, ends, left: left() };\n}\n\n/** This function starts a process for `superviseCases`, with no shell. The process shares the output of the supervisor, and `stop` stops its tree at once. */\nexport function startSupervisedProcess(argv: readonly string[], options: { readonly cwd?: string; readonly env?: NodeJS.ProcessEnv } = {}): SupervisedChild {\n const [program, ...rest] = argv;\n // On POSIX, the child leads its own process group, so a signal to the group reaches the grandchildren.\n const proc = spawn(program!, rest, { stdio: [\"ignore\", \"inherit\", \"inherit\"], windowsHide: true, detached: process.platform !== \"win32\", ...options });\n const exited = new Promise<number | null>((resolve) => {\n proc.on(\"error\", () => resolve(null));\n proc.on(\"close\", (code) => resolve(code));\n });\n return { stop: () => stopTree(proc, \"SIGKILL\"), exited };\n}\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,mBAAmB;;AAGhC,MAAa,kBAAkB;;AA+E/B,SAAgB,aAAa,MAAc,MAAoB,KAAK,KAAmB;CACrF,MAAM,SAAS,UAA+B,eAAe,MAAM,GAAG,KAAK,UAAU,KAAK,EAAE,GAAG;CAC/F,OAAO;EACL,QAAQ,IAAI,QAAQ,OAAO,MAAM;GAAE,OAAO;GAAS;GAAI;GAAO,IAAI,IAAI;EAAE,CAAC;EACzE,MAAM,OAAO,MAAM;GAAE,OAAO;GAAO;EAAG,CAAC;CACzC;AACF;;AAGA,SAAS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"version":3,"file":"supervise.js","names":[],"sources":["../src/supervise.ts"],"sourcesContent":["/**\n * The runner of cases with a time budget. A case runs in a child process, so a hard stop works on code that does not return.\n * One child runs each case that is left. The child writes the start and the end of each case to a progress file.\n * When a case passes its budget, the supervisor stops the child, reports the case, and starts a new child on the cases that are left.\n * Only an overrun costs a new child, so the times of the other cases do not change.\n */\n\nimport { spawn } from \"node:child_process\";\nimport { appendFileSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { stopTree } from \"./tree.ts\";\n\n/** The count of overruns in one group, after which the other cases of the group do not run. */\nexport const DEFAULT_OVERRUNS = 2;\n\n/** The time between two reads of the progress file, in milliseconds. */\nexport const DEFAULT_POLL_MS = 1000;\n\n/** One case of a supervised run. */\nexport interface SupervisedCase {\n readonly id: string;\n /** The time budget of each stage of the case, in milliseconds. */\n readonly budgetMs: number;\n /**\n * The group of each stage of the case. An overrun in a stage counts for the group of that stage only.\n * A case with stages `pack` and `route` can thus count against a router, or against a packer, and not against both.\n */\n readonly groups?: Readonly<Record<string, string>>;\n /**\n * The place of the case in its groups, for example its input size. The default is 0.\n * Overruns count for each group and rank. They stop the cases of that group at that rank and above, and a smaller rank goes on.\n */\n readonly rank?: number;\n}\n\n/** The end of a case that did not finish: an overrun, which is measured, or a skip, which is not. */\nexport type SupervisedEnd =\n | { readonly kind: \"over-budget\"; readonly id: string; readonly budgetMs: number; readonly stage: string }\n | { readonly kind: \"not-run\"; readonly id: string; readonly budgetMs: number; readonly group: string; readonly because: readonly string[] };\n\n/** One running child. */\nexport interface SupervisedChild {\n /** This function stops the child and its tree at once. */\n stop(): void;\n /** The exit code of the child, or `null` when a signal stopped it. */\n readonly exited: Promise<number | null>;\n}\n\n/** The options of `superviseCases`. */\nexport interface SuperviseOptions {\n /** The cases, in the order of the run. */\n readonly cases: readonly SupervisedCase[];\n /** The ids of the cases of an earlier run. These cases do not run. */\n readonly done?: ReadonlySet<string>;\n /**\n * The ends of an earlier run of these cases, in their order. These cases do not run, and an `over-budget` end needs its case in `cases`.\n * Each `over-budget` end counts for its group, so a stop and a resume give the same ends as a run with no stop.\n */\n readonly earlier?: readonly SupervisedEnd[];\n /** The file that the child writes with `caseProgress`. The supervisor makes it empty at the start. */\n readonly progressFile: string;\n /** This function starts a child on the ids that are left. */\n readonly start: (left: readonly string[]) => SupervisedChild;\n /** This function is the callback for the record of each case that did not finish. */\n readonly onEnd: (end: SupervisedEnd) => void;\n /** The default is `DEFAULT_OVERRUNS`. */\n readonly overruns?: number;\n /** The default is `DEFAULT_POLL_MS`. */\n readonly pollMs?: number;\n /** The clock of the supervisor. It is the clock of `caseProgress`. */\n readonly now?: () => number;\n}\n\n/** The result of `superviseCases`. */\nexport interface SuperviseResult {\n /** The exit code of the last child, or `null` when no child ran or a signal stopped the last child. */\n readonly code: number | null;\n /** The count of the children. */\n readonly starts: number;\n readonly ends: readonly SupervisedEnd[];\n /** The ids that have no result, because the last child ended before them. */\n readonly left: readonly string[];\n}\n\n/** The writer of a progress file, for the child. */\nexport interface CaseProgress {\n /** This function tells that a stage of a case starts. Each stage has its own budget. */\n start(id: string, stage?: string): void;\n /** This function tells that a case ended. Call it after the result of the case is on the disk. */\n end(id: string): void;\n}\n\ninterface ProgressEvent {\n readonly event: \"start\" | \"end\";\n readonly id: string;\n readonly stage?: string;\n readonly at?: number;\n}\n\n/** This function gives the writer of a progress file. Each write is synchronous, so it works in a loop that does not yield. */\nexport function caseProgress(file: string, now: () => number = Date.now): CaseProgress {\n const write = (event: ProgressEvent): void => appendFileSync(file, `${JSON.stringify(event)}\\n`);\n return {\n start: (id, stage = \"\") => write({ event: \"start\", id, stage, at: now() }),\n end: (id) => write({ event: \"end\", id }),\n };\n}\n\n/** The reader of a progress file: each call gives the events of the lines that are whole and were not read. */\nfunction progressReader(file: string): () => ProgressEvent[] {\n let read = 0;\n return () => {\n const text = readFileSync(file, \"utf8\");\n const whole = text.slice(0, text.lastIndexOf(\"\\n\") + 1);\n const lines = whole.slice(read).split(\"\\n\").filter((line) => line !== \"\");\n read = whole.length;\n return lines.map((line) => JSON.parse(line) as ProgressEvent);\n };\n}\n\n/**\n * This function runs the cases and holds each case to its budget.\n *\n * - A stage over its budget stops the child, and `onEnd` gets `over-budget`. The next child runs the cases that are left.\n * - After `overruns` overruns in one group at one rank, each other case of the group at that rank or above ends as `not-run`.\n * The end has the ids of those overruns.\n * - A case of a smaller rank goes on, and an overrun at another rank does not count. With no ranks, all cases of a group have one rank.\n * - A case in `done` or `earlier` does not run. A case that ended, or that has an end from `onEnd`, does not run again.\n * - An `over-budget` end of `earlier` counts as an overrun of this run. `onEnd` does not get the end again.\n * - A child that ends without a stop ends the run. Its exit code is the code of the result.\n * - A line of the progress file that is not JSON stops the child, and this function then throws the error.\n */\nexport async function superviseCases(options: SuperviseOptions): Promise<SuperviseResult> {\n const { cases, progressFile, start, onEnd, now = Date.now } = options;\n const limit = options.overruns ?? DEFAULT_OVERRUNS;\n const pollMs = options.pollMs ?? DEFAULT_POLL_MS;\n const byId = new Map(cases.map((c) => [c.id, c]));\n for (const c of cases) {\n if (c.rank !== undefined && !Number.isFinite(c.rank)) throw new RangeError(`The case \"${c.id}\" has the rank ${c.rank}. A rank must be a finite number.`);\n }\n const finished = new Set(options.done ?? []);\n const groupOverruns = new Map<string, Map<number, string[]>>();\n const ends: SupervisedEnd[] = [];\n const left = (): string[] => cases.filter((c) => !finished.has(c.id)).map((c) => c.id);\n const report = (end: SupervisedEnd): void => {\n finished.add(end.id);\n ends.push(end);\n onEnd(end);\n };\n const countOverrun = (id: string, stage: string): void => {\n const overrun = byId.get(id);\n const group = overrun?.groups?.[stage];\n if (group === undefined) return;\n const rank = overrun?.rank ?? 0;\n const ranks = groupOverruns.get(group) ?? new Map<number, string[]>();\n const ids = [...(ranks.get(rank) ?? []), id];\n ranks.set(rank, ids);\n groupOverruns.set(group, ranks);\n if (ids.length < limit) return;\n for (const c of cases) {\n if (!finished.has(c.id) && (c.rank ?? 0) >= rank && Object.values(c.groups ?? {}).includes(group)) report({ kind: \"not-run\", id: c.id, budgetMs: c.budgetMs, group, because: ids.slice(0, limit) });\n }\n };\n\n const earlier = options.earlier ?? [];\n for (const end of earlier) {\n if (end.kind === \"over-budget\" && !byId.has(end.id)) throw new RangeError(`The case \"${end.id}\" of the option earlier is not in the option cases.`);\n finished.add(end.id);\n }\n for (const end of earlier) {\n if (end.kind === \"over-budget\") countOverrun(end.id, end.stage);\n }\n\n writeFileSync(progressFile, \"\");\n const readEvents = progressReader(progressFile);\n const state: { running?: { readonly id: string; readonly stage: string; readonly at: number } | undefined; exit?: { readonly code: number | null } | undefined } = {};\n const update = (): void => {\n for (const event of readEvents()) {\n if (event.event === \"start\") {\n state.running = { id: event.id, stage: event.stage ?? \"\", at: event.at ?? now() };\n } else {\n finished.add(event.id);\n if (state.running?.id === event.id) state.running = undefined;\n }\n }\n };\n\n // A function makes this reset, so that the checks of the loop see the declared types of the state.\n const forgetChild = (): void => {\n state.running = undefined;\n state.exit = undefined;\n };\n\n let starts = 0;\n let code: number | null = null;\n while (left().length > 0) {\n forgetChild();\n starts += 1;\n const child = start(left());\n const exited = child.exited.then((value) => {\n state.exit = { code: value };\n });\n let over: { readonly id: string; readonly stage: string; readonly budgetMs: number } | undefined;\n while (state.exit === undefined && over === undefined) {\n let timer: ReturnType<typeof setTimeout> | undefined;\n await Promise.race([exited, new Promise((resolve) => (timer = setTimeout(resolve, pollMs)))]);\n clearTimeout(timer);\n try {\n update();\n } catch (error) {\n // A progress file that cannot be read cannot hold the child to its budget, so the child must not outlive the supervisor.\n child.stop();\n await exited;\n throw error;\n }\n const current = state.running;\n const budgetMs = current === undefined ? undefined : byId.get(current.id)?.budgetMs;\n if (state.exit === undefined && current !== undefined && budgetMs !== undefined && now() - current.at > budgetMs) over = { id: current.id, stage: current.stage, budgetMs };\n }\n if (over === undefined) {\n code = state.exit?.code ?? null;\n break;\n }\n child.stop();\n await exited;\n code = null;\n update();\n // The case can end between the read and the stop. Then its result is on the disk, and it has no overrun.\n if (finished.has(over.id)) continue;\n report({ kind: \"over-budget\", ...over });\n countOverrun(over.id, over.stage);\n }\n return { code, starts, ends, left: left() };\n}\n\n/** This function starts a process for `superviseCases`, with no shell. The process shares the output of the supervisor, and `stop` stops its tree at once. */\nexport function startSupervisedProcess(argv: readonly string[], options: { readonly cwd?: string; readonly env?: NodeJS.ProcessEnv } = {}): SupervisedChild {\n const [program, ...rest] = argv;\n // On POSIX, the child leads its own process group, so a signal to the group reaches the grandchildren.\n const proc = spawn(program!, rest, { stdio: [\"ignore\", \"inherit\", \"inherit\"], windowsHide: true, detached: process.platform !== \"win32\", ...options });\n const exited = new Promise<number | null>((resolve) => {\n proc.on(\"error\", () => resolve(null));\n proc.on(\"close\", (code) => resolve(code));\n });\n return { stop: () => stopTree(proc, \"SIGKILL\"), exited };\n}\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,mBAAmB;;AAGhC,MAAa,kBAAkB;;AAoF/B,SAAgB,aAAa,MAAc,MAAoB,KAAK,KAAmB;CACrF,MAAM,SAAS,UAA+B,eAAe,MAAM,GAAG,KAAK,UAAU,KAAK,EAAE,GAAG;CAC/F,OAAO;EACL,QAAQ,IAAI,QAAQ,OAAO,MAAM;GAAE,OAAO;GAAS;GAAI;GAAO,IAAI,IAAI;EAAE,CAAC;EACzE,MAAM,OAAO,MAAM;GAAE,OAAO;GAAO;EAAG,CAAC;CACzC;AACF;;AAGA,SAAS,eAAe,MAAqC;CAC3D,IAAI,OAAO;CACX,aAAa;EACX,MAAM,OAAO,aAAa,MAAM,MAAM;EACtC,MAAM,QAAQ,KAAK,MAAM,GAAG,KAAK,YAAY,IAAI,IAAI,CAAC;EACtD,MAAM,QAAQ,MAAM,MAAM,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,SAAS,SAAS,EAAE;EACxE,OAAO,MAAM;EACb,OAAO,MAAM,KAAK,SAAS,KAAK,MAAM,IAAI,CAAkB;CAC9D;AACF;;;;;;;;;;;;;AAcA,eAAsB,eAAe,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
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/rigor-bench",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.13",
|
|
5
5
|
"description": "The paired-time records of a bench: the order that turns each round, the ratio of each case, and the time verdict against the band of an A/A arm.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"benchmark",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@mark1russell7/rigor-generators": "^0.1.5",
|
|
55
|
-
"@mark1russell7/rigor-statistics": "^0.1.
|
|
55
|
+
"@mark1russell7/rigor-statistics": "^0.1.11"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@mark1russell7/cue": "^2.0.0",
|