@mark1russell7/rigor-bench 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/build/index.d.ts +29 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +27 -1
- package/build/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -122,14 +122,17 @@ v.next; // the first rung that is not
|
|
|
122
122
|
v.failed; // true when a locked rung is not within
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
There are
|
|
125
|
+
There are four kinds of budget:
|
|
126
126
|
|
|
127
127
|
| Kind | Evidence | The verdict |
|
|
128
128
|
| --- | --- | --- |
|
|
129
129
|
| `median` | Rounds and an A/A arm | `budgetVerdict`, so the rules of a budget apply. |
|
|
130
|
+
| `quantile` | The values, and optional `censored` bounds | The distribution-free interval of the quantile at 95 % against the limit. |
|
|
130
131
|
| `rate` | Failures and trials | The Wilson interval at 95 % against the limit. |
|
|
131
132
|
| `worst` | The value of each drill | The largest value against the limit. One bad drill is `beyond`. |
|
|
132
133
|
|
|
134
|
+
- A p99 needs 368 independent values for an upper bound at 95 %. A p95 needs 72 and a p99.9 needs 3,688. `quantileSamples` gives the count. With fewer values, the verdict is `cannot decide` or `beyond`. It is not `within`. Latencies of one run can follow each other: space the samples apart, or give one value for each run.
|
|
135
|
+
- An arrival with no reply goes in `censored`, and an arrival that was not sent goes there too. Each value is a lower bound: the time that the arrival waited. The low end of the interval reads the bounds, and the high end reads each censored value as `Infinity`. Thus a `beyond` can come from the bounds alone, and a `within` needs real replies up to the upper rank. Do not put a censored value in `values`: its bound is low, and the verdict can be a false `within`.
|
|
133
136
|
- A failed rate of 0 of 38,500 holds a limit of 0.01 %. A failed rate of 0 of 30,000 is `cannot decide`, because the Wilson bound of that run is 0.0128 %.
|
|
134
137
|
- A locked rung fails when it is `beyond` and when it is `cannot decide`. A skipped test is not a pass.
|
|
135
138
|
- The verdict reads the newest record of each rung, so an old pass does not hide a new failure. With `maxAgeDays`, an older record gives `cannot decide`.
|
package/build/index.d.ts
CHANGED
|
@@ -99,8 +99,30 @@ interface WorstBudget {
|
|
|
99
99
|
/** The number of drills that a verdict needs, 1 or more. With fewer, the budget is `cannot decide`. */
|
|
100
100
|
readonly minDrills: number;
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* A budget on a high quantile, for example the p99 of a read. A record gives the values. The verdict is the distribution-free
|
|
104
|
+
* interval of the quantile against the limit. A p99 needs 368 independent values at the level 0.95: refer to `quantileSamples`.
|
|
105
|
+
* Successive times of one run can follow each other. Space them apart, or give one value for each run.
|
|
106
|
+
*
|
|
107
|
+
* The evidence can also hold `censored`: a lower bound for each arrival with no reply, and for each arrival that was not
|
|
108
|
+
* sent. The bound is the time that the arrival waited. The true value is that bound or more, with no upper limit. Thus the
|
|
109
|
+
* low end of the interval reads the bounds, and the high end reads each censored value as `Infinity`. A `beyond` stays
|
|
110
|
+
* provable from the bounds alone. A `within` needs real replies up to the upper rank of the interval.
|
|
111
|
+
*/
|
|
112
|
+
interface QuantileBudget {
|
|
113
|
+
readonly kind: "quantile";
|
|
114
|
+
readonly measure: string;
|
|
115
|
+
/** The unit of the limit and of the values. */
|
|
116
|
+
readonly unit: string;
|
|
117
|
+
/** The quantile, more than 0 and less than 1, for example 0.99. */
|
|
118
|
+
readonly quantile: number;
|
|
119
|
+
/** The largest quantile that the budget permits. */
|
|
120
|
+
readonly limit: number;
|
|
121
|
+
/** The level of the interval. The default is 0.95. */
|
|
122
|
+
readonly level?: number;
|
|
123
|
+
}
|
|
102
124
|
/** One budget of a rung. */
|
|
103
|
-
type RungBudget = MedianBudget | RateBudget | WorstBudget;
|
|
125
|
+
type RungBudget = MedianBudget | QuantileBudget | RateBudget | WorstBudget;
|
|
104
126
|
/** One rung of a ladder. */
|
|
105
127
|
interface Rung {
|
|
106
128
|
/** The name of the rung, unique in the ladder. */
|
|
@@ -127,6 +149,11 @@ type RungEvidence = {
|
|
|
127
149
|
readonly measure: string;
|
|
128
150
|
readonly rounds: readonly BudgetRound[];
|
|
129
151
|
readonly aa: readonly BudgetRound[];
|
|
152
|
+
} | {
|
|
153
|
+
readonly kind: "quantile";
|
|
154
|
+
readonly measure: string;
|
|
155
|
+
readonly values: readonly number[];
|
|
156
|
+
readonly censored?: readonly number[];
|
|
130
157
|
} | {
|
|
131
158
|
readonly kind: "rate";
|
|
132
159
|
readonly measure: string;
|
|
@@ -609,5 +636,5 @@ interface Rounds {
|
|
|
609
636
|
* keeps the work.
|
|
610
637
|
*/
|
|
611
638
|
export declare function timeRounds(arms: Readonly<Record<Arm, () => number>>, options: RoundsOptions): Rounds;
|
|
612
|
-
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 JobLimitVerdict, type JobRecords, type JobVerdict, type Ladder, type LadderDimension, type LadderOptions, type LadderVerdict, type LimitOptions, type LimitOutcome, type LimitVerdict, type MedianBudget, type NoiseCheck, type PairedTime, type PoolFacts, type PoolOptions, type PooledJob, type PooledLimitVerdict, type PooledRecords, type PooledVerdict, type Power, type PowerOptions, 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 };
|
|
639
|
+
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 JobLimitVerdict, type JobRecords, type JobVerdict, type Ladder, type LadderDimension, type LadderOptions, type LadderVerdict, type LimitOptions, type LimitOutcome, type LimitVerdict, type MedianBudget, 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 };
|
|
613
640
|
//# 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/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;;qBC3GtG;;UAGI;WACN;;WAEA;;;UAIM;WACN;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;WACN;WACA;;WAEA;;;UAIM;WACN;WACA;WACA;;WAEA;;WAEA;;;KAIC,aAAa,eAAe,aAAa;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/budget.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,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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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as checkPairedTime, r as firstArm, t as caseRatios } from "./paired.js";
|
|
2
|
-
import { bootstrapMedian, bootstrapTwo, compareRatios, median, medianInterval, quantile, wilson } from "@mark1russell7/rigor-statistics";
|
|
2
|
+
import { bootstrapMedian, bootstrapTwo, compareRatios, median, medianInterval, quantile, quantileInterval, quantileSamples, wilson } from "@mark1russell7/rigor-statistics";
|
|
3
3
|
import { random } from "@mark1russell7/rigor-generators";
|
|
4
4
|
// src/budget.ts
|
|
5
5
|
/**
|
|
@@ -115,6 +115,8 @@ function budgetProblems(where, budget) {
|
|
|
115
115
|
if (budget.kind === "rate" && budget.limit > 1) out.push(`${name}: a rate limit is at most 1, not ${budget.limit}.`);
|
|
116
116
|
if (budget.kind === "median" && !(Number.isFinite(budget.maxDifference) && budget.maxDifference >= 0)) out.push(`${name}: the largest difference is finite and 0 or more, not ${budget.maxDifference}.`);
|
|
117
117
|
if (budget.kind === "worst" && !(Number.isInteger(budget.minDrills) && budget.minDrills >= 1)) out.push(`${name}: the number of drills is a whole number of 1 or more, not ${budget.minDrills}.`);
|
|
118
|
+
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}.`);
|
|
119
|
+
if (budget.kind === "quantile" && budget.level !== void 0 && !(budget.level > 0 && budget.level < 1)) out.push(`${name}: a level is more than 0 and less than 1, not ${budget.level}.`);
|
|
118
120
|
return out;
|
|
119
121
|
}
|
|
120
122
|
/** This function gives the problems of one rung, in the order of its fields. */
|
|
@@ -185,6 +187,29 @@ function worstResult(budget, values) {
|
|
|
185
187
|
reason: `The measure ${JSON.stringify(budget.measure)} is "${outcome}" (${facts}, ${budget.minDrills} drills needed).`
|
|
186
188
|
};
|
|
187
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* This function gives the verdict of a quantile: its distribution-free interval against the limit. With censored values, the
|
|
192
|
+
* low end reads their bounds and the high end reads them as `Infinity`. Each true sample has its interval inside that one.
|
|
193
|
+
*/
|
|
194
|
+
function quantileResult(budget, values, censored) {
|
|
195
|
+
const level = budget.level ?? .95;
|
|
196
|
+
const needed = quantileSamples(budget.quantile, level);
|
|
197
|
+
const say = (outcome, facts) => ({
|
|
198
|
+
measure: budget.measure,
|
|
199
|
+
outcome,
|
|
200
|
+
reason: `The measure ${JSON.stringify(budget.measure)} is "${outcome}" (${facts}, ${needed} values needed).`
|
|
201
|
+
});
|
|
202
|
+
const open = censored.length > 0;
|
|
203
|
+
const bounds = [...values, ...censored];
|
|
204
|
+
if (bounds.length === 0) return say("cannot decide", `0 values, limit ${budget.limit} ${budget.unit}`);
|
|
205
|
+
if (values.some((value) => Number.isNaN(value))) return say("cannot decide", "the values have a NaN");
|
|
206
|
+
if (!censored.every((value) => Number.isFinite(value))) return say("cannot decide", "a censored value is not a finite number");
|
|
207
|
+
const lowest = quantileInterval(bounds, budget.quantile, level);
|
|
208
|
+
const highest = open ? quantileInterval([...values, ...censored.map(() => Infinity)], budget.quantile, level) : lowest;
|
|
209
|
+
const [count, point] = open ? [`${values.length} values and ${censored.length} censored`, "at least"] : [`${values.length} values`, "at"];
|
|
210
|
+
const facts = `${count}, quantile ${budget.quantile} ${point} ${quantile(bounds, budget.quantile, "nearest-rank")} ${budget.unit}, interval ${lowest.low} to ${highest.high}, limit ${budget.limit}`;
|
|
211
|
+
return say(highest.high <= budget.limit ? "within" : lowest.low > budget.limit ? "beyond" : "cannot decide", facts);
|
|
212
|
+
}
|
|
188
213
|
/** This function gives the verdict of one budget from the evidence of a record. */
|
|
189
214
|
function budgetResult(budget, evidence) {
|
|
190
215
|
const found = evidence.find((e) => e.measure === budget.measure);
|
|
@@ -206,6 +231,7 @@ function budgetResult(budget, evidence) {
|
|
|
206
231
|
reason: v.reason
|
|
207
232
|
};
|
|
208
233
|
}
|
|
234
|
+
if (budget.kind === "quantile" && found.kind === "quantile") return quantileResult(budget, found.values, found.censored ?? []);
|
|
209
235
|
if (budget.kind === "rate" && found.kind === "rate") return rateResult(budget, found.failures, found.trials);
|
|
210
236
|
if (budget.kind === "worst" && found.kind === "worst") return worstResult(budget, found.values);
|
|
211
237
|
return none(`the budget is ${budget.kind}, and the evidence is ${found.kind}`);
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["round","round"],"sources":["../src/budget.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 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 { 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/** One budget of a rung. */\nexport type RungBudget = MedianBudget | 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: \"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 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/** 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 === \"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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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/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 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,E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AAC,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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/rigor-bench",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.10",
|
|
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.10"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@mark1russell7/cue": "^2.0.0",
|