npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mark1russell7/rigor-bench

v0.3.30

Published

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.

Readme

@mark1russell7/rigor-bench

The paired-time records of a bench, and the time verdict against an A/A arm. This package is the first part of the shared bench harness of rigor.

npm install @mark1russell7/rigor-bench

The method

  • Each round runs the two arms of a pair on one case, one after the other. Arm a is the baseline, and arm b is the candidate.
  • The order turns each round (firstArm). Thus a warm cache or a slow start does not always help the same arm.
  • A run with three or more arms in one child order uses armOrder. A plain turn of the arms does not turn each pair evenly.
  • An A/A pair runs the same code in its two arms. Its ratios show how far apart two equal arms come on the machine.
  • The ratio of a case is b / a over its rounds (caseRatios).
  • The default rule difference gives the bootstrap interval of the candidate median over the A/A median. The verdict compares it with 1.

Give a verdict

import { firstArm, timeVerdict, type PairedTime } from "@mark1russell7/rigor-bench";

const first = firstArm(round, caseIndex);         // "a" or "b": run this arm first
const records: PairedTime[] = [{ case: "board-1", round: 0, first: "a", a: 12.1, b: 10.4 }];
const v = timeVerdict(records, aaRecords);

v.outcome;                                        // "faster", "slower", "same" or "cannot decide"
v.reason;                                         // one sentence with the interval and the band
v.comparison;                                     // the cases that gain and drop beyond the band

The functions

| Function | What it gives | | --- | --- | | growthVerdict(rounds, options) | The growth of a cost for each step of size, from a ratio inside each job, against a limit, for example 15 times for each 10 times. | | runCost(cells, probes, options) | The minutes of a bench run before it starts, on each CPU model: the cells times the calls times the time of one call. | | firstArm(round, offset) | The arm that runs first. The order turns each round, and an odd offset starts with arm b. | | armOrder(arms, round) | The order of any count of arms in a round. Each pair of arms has each order within 1 after each count of rounds. A report that keeps no first for each pair states the order that it used, so that a reader can make first again. | | balancedRounds(arms) | The count of rounds that balances armOrder: 2 times the count of arms. Each arm is then at each position 2 times. | | mergeCaseModules(modules) | The cases of a list of modules in one record, and the module of each case. Two cases with one name are an error. | | moduleListGaps(files, listed) | The modules of a folder that are not in the list, and the listed modules that are not in the folder. | | checkPairedTime(record) | The record, or a RangeError for a time that is not a finite number above 0. | | caseRatios(records) | The ratio of each case. It refuses 2 records of one round, and an order that did not turn. | | orderSize(records) | The count of records per first arm, the order effect, and the amount that unequal counts can move a mean. This size is a guide, because a verdict reads a median. | | aaBand(aa, options) | The band of the A/A arm, symmetric on a log scale. The kind median (the default) holds the A/A median, and the kind case holds one A/A case. It needs 5 cases or more. | | timeVerdict(candidate, aa, options) | The outcome of the rule difference (the default) or band. | | verdictMargin(options) | The margin of the rule difference on a log scale: the larger of margin and the noise of the pooled band. An interval in [exp(-margin), exp(margin)] is same. | | aaSpread(aa, level) | The A/A spread: the level quantile of abs(log(ratio)) over the A/A cases. The default level is 0.9. | | pooledBand(pool, level) | The pooled band: the larger of the floor and the A/A spread of the records of earlier runs. | | caseIntervals(records, level) | The ratio of each case with a distribution-free interval of its median over the rounds. The level 0.95 needs 6 rounds or more. | | limitVerdict(candidate, aa, options) | The verdict of the claim "the ratio of each case is at most limit": within, beyond or cannot decide. aaFrom: "rounds" takes the A/A noise from the rounds of each case. noiseCap stops a pass on a noisy run. | | tailLimitVerdict(candidate, aa, options) | The verdict of the claim "the median and a high value of each case are at most their limits", for a bench with few rounds. | | caseTails(records, rank) | The value at one rank of the ratios of each case, from the largest. | | processVerdict(reads, options) | The verdict of each case over its first k valid processes: the median against a limit, and the count above a slow line. | | processCaseLine(case) | One line of a case of processVerdict: the outcome, the median, the slow count and the ratio of each process. | | isValidRead(read, noiseCap?) | True when the A/A band of a process read contains 1 and its noise is at most noiseCap. Without a cap, a read with no band is valid. | | readNoise(read) | The A/A noise of a process read on a log scale: the larger distance from 0 of the logs of the ends of its band. | | processNoiseCap(jobs, options) | The noise cap of one case from the reads of earlier quiet jobs: a quantile of the read noise, its interval and the decide rate at the cap. | | processLimits(jobs, options) | The limits of processVerdict for one case from the reads of earlier jobs: the limit, the slow line and maxSlow, with their derivation. | | modelTest(reads, options) | The read of each CPU model against the rest, for each case: differs, no read, too-few or not asked. | | visibleShift(values, rest, level, direction, options) | The smallest shift in one direction that a test can see at this count and level, and the smallest p of this count. | | modelRowText(row, family) | The words of one row. No word says that a model is the same as the rest. | | limitOnModel(limits, model) | The limit of a gain on one CPU model: the gain limit, or the ceiling with its words. | | cpuEntry(table, cpu) | The entry of a table whose key is a part of the CPU name, with the case ignored, or the entry other. | | modelRuns(values, options) | The values of each CPU model grouped by CI run, for each model with minimumRuns runs or more. Since 0.3.6. | | modelTable(values, limit, options) | A limit for each CPU model with minimumRuns runs or more, and the pooled limit other. Since 0.3.6. | | recentRuns(items, read, options) | The items of the last perModel CI runs of each CPU model. A limit from a window of recent runs can go down again, and a limit from all the runs can only grow. Since 0.3.7. | | armModels(pairs) | The CPU models of each arm of a set of pairs, and if all the reads come from one known model. | | candidateLimits(reads, rule) | The candidate limit of each case on each CPU model: the mean plus k standard deviations, from 5 reads or more. | | freezeLimits(measure, candidates, stamp, rule) | A file of frozen limits, with the values, the commit and the date of each limit. | | runLimit(values, options) | The limit of the rule of the gate limits: the worst value of 5 runs or more plus their spread, rounded away from the values. | | aaStats(aa, level) | The A/A statistics of each case of one job: the median log ratio and the spread of the rounds. | | aaOrders(aa, level) | The A/A ratio of each case over all rounds and over the rounds of each order, with the interval of each median. | | aaLimits(jobs, options) | The margin and the noise cap of each family of cases from the A/A statistics of the jobs, and the jobs that went out. | | aaLimitOf(limits, family) | The options margin and noiseCap of timeVerdict for a family, or the fallback limits. | | checkModelLimits(file) | The faults of a file of frozen limits. The function computes each limit again from its values. | | modelLimitRead(file, read) | The read of one value against the frozen limit of its CPU model: within, beyond or no read. | | limitChanges(before, after) | The change of each limit between two files, and each looser limit that has no new reason. | | tailFalseFails(aa, options) | The cases of an A/A arm that the rule of tailLimitVerdict fails, and apart from these the cases with a limit under 1. | | gateOf(cases) | The gate of a list of case outcomes: pass, block or no read. | | gateLine(cases, options) | The check line of a read: the blocks and the no-reads with each case, the reason and the CPU models, or undefined when each case passed. | | jobModels(envs, options) | The count of the jobs on each CPU model, sorted by model, for the job form of the models of gateLine. The option cores keeps the cores. | | writeGateLine(line, outputs) | The line as an annotation of GitHub Actions, an error for an enforced gate or a warning, and as a line of the step summary. | | gateLineCli(argv, io) | The command of the bin rigor-gate-line: a gate line from a JSON document of a shell step. | | gateVerdictWord(outcome) | The word of a gate outcome in the verdict file of a gate job: pass, block or no-read. | | writeGateVerdict(outcome, file) | The word of a gate outcome as one line of the verdict file. The default file is the variable GATE_VERDICT_FILE. | | holdGate(gate, heads, read) | The hold of a gate: pass, held, accepted or no read. A record accepts the cost of a slower case on one head arm. | | holdAcceptances(files), readHoldAcceptances(dir) | The records that accept the cost of a hold, and the faults of the files that are not correct. | | holdPasses(outcome), holdVerdictWord(outcome) | Only pass and accepted pass. The verdict word of accepted is pass, and of held is block. | | notSlowerVerdict(jobs, options) | The gate of the claim "not slower by more than the margin", with looks and a family level. | | budgetVerdict(rounds, aa, options) | The verdict of the claim "the median of each case is at most limit", for one build: within, beyond or cannot decide. | | budgetLooksVerdict(rounds, aa, options) | The budget verdict of a run that adds rounds to the cases with no outcome, up to a stated budget. | | budgetLookSpend(looks) | The chance of error that a list of looks spends. | | overLimit(firstMs, limitMs) | True when a first run is over the limit. With no limit, no run is over it. | | runMethod(firstMs, options) | The method of one case: two runs, sentinel or one run. | | sameResult(method, firstHash, secondHash) | The claim that the result stays the same: true, false, or null for one run. | | sentinelCases(cases, options) | The cases that keep their second run over the limit: the smallest one, and one rotating case of each group. | | firstAgainstSecond(rows) | The ratio of the second time over the first time of each group, with firstAgainstSecondLine for its text. | | timeRounds(arms, options) | The timed rounds of one case in one process: a warm-up, a batch of at least the target time, and the order of firstArm. | | slopeVerdict(rounds, options) | The verdict of a slope claim from a ladder on a log-log scale, with the A/A check of each run: within, beyond or cannot decide. | | roundSlope(rungs) | The least-squares slope of log value against log size of one round of 3 rungs or more. | | timeArmRounds(options) | The timed rounds of one case in one process for a base and 1 or more candidates, with the order of armOrder, an A/A pair and the span of each timed batch. | | verdictPower(options) | The share of each outcome over seeded benches with a known ratio: the power test of a rule. | | familyRead(items, level) | The reads of a family of cases as a report: Holm over the cases, each job alone, and both. Each read changes only slower and faster. | | familyPower(options) | The false-slower share of a family and the share of a slow case read, for each read, over seeded families. | | balanceOrders(records) | The records of each case with a turned order. It removes the extra records of the larger order, with the highest rounds first. | | poolRecords(jobs) | The pool of the jobs: the merged and balanced records, the records of each job, and the skipped cases. | | pooledVerdict(jobs, options) | The verdict of the merged records of all jobs, with the verdict of each job alone as a guard. | | pooledLimitVerdict(jobs, options) | The limit verdict of the merged records of all jobs, with the limit verdict of each job alone as a guard. | | armVerdicts(run, aaPair, options) | The verdict of each candidate pair of a run against its A/A pair. | | benchEnv() | From /fresh: the computer of this process, with the CPU model, the runner and the kind of the machine (machine, on Linux). | | cpuInfoMachine(text) | The kind of the machine from the text of /proc/cpuinfo: the family, the model number, the stepping, the microcode and the cache size of the first processor. For an ARM CPU, it gives the implementer, the part, the variant and the revision. Two levels of time on one CPU model can come from two kinds of machine. The record has no clock speed, because the speed of the file changes in one job. | | childLine(stdout) | From /fresh: the last JSON line of a child, with its time ms, its hash and the reason of a skip. | | pairOrder(pairs, round, caseIndex) | From /fresh: the order of the pairs of one case in one round, and the first arm of each pair. | | startProcess(argv, options) | From /fresh: the default start of a child, with no shell, and a stop at the time limit or the output limit. The option input gives the standard input of the child. | | freshRun(options) | From /fresh: the records of each pair, with each arm in its own fresh child process. With order: "arms", the pairs of a round share one base child. | | freshArms(options) | From /fresh: one fresh child for each arm in each round, in the order of armOrder, with A/A records and fixture hashes. | | armTimes(processes) | From /fresh: the median, the 10th and the 90th percentiles, their ratio, and the least and the greatest time of each arm over its children. | | checkFixtures(folder, files, options) | From /fresh: the hash and the size of each fixture file, or an error that names each file that is not the pinned file. | | fixtureDifferences(a, b) | From /fresh: the fixture files that two records do not share with the same hash. | | timeArm(run, options) | The child side of freshRun: the median time of one call of one arm, over calibrated samples. | | peakRss() | From /fresh: the memory peak of this process in bytes, for the child line. | | processMemory(options) | From /fresh: the memory of this process at the time of the call: the resident set, its peak, its anonymous part and its file part from /proc/self/status, and the heap. | | statusMemory(text) | From /fresh: the fields of the resident set in bytes from the text of /proc/<pid>/status, or null. | | heapAfterGc() | From /fresh: the used heap after a full garbage collection, in a child with the Node flag --expose-gc. | | HEAP_READ_FLAGS | From /fresh: the Node flags of a child that reads its heap, --expose-gc and --single-threaded. With background threads, the heap of equal children can differ by some KiB. freshArms warns on an arm with --expose-gc only. | | memoryPeak(a, b) | From /fresh: the larger value of each field of two memory readings. | | watchMemory(options) | From /fresh: a reading of the memory at an interval, with the peak of each field. | | watchHeap(options) | From /fresh: the peaks of the used heap and of the live heap, and the GC time, over the GC events of a watch. | | containerStart(options) | From /fresh: a start of each child in a Docker container with the image, the memory, the swap and the CPUs of a target machine, and its sidecars. | | containerArgv(options, name, argv, cwd, interactive) | From /fresh: the argv of docker run for one child of containerStart. With interactive, the child reads the standard input of docker run. | | PEAK_SCRIPT | From /fresh: the script of /bin/sh that starts a child of containerStart with the option peak, and then reads the memory peak and the count oom_kill of its container. | | SAMPLE_SCRIPT | From /fresh: the script of /bin/sh for the option sampleMs. It also samples the working set of the container during the child. | | SAMPLE_MS | From /fresh: the least and the largest interval of the option sampleMs, 10 and 60000 milliseconds. | | diskOf(path, read) | From /fresh: the whole disk of the host that holds a path, as /dev/<name>, for the disk limits of a container. | | dropPageCache(start) | From /fresh: a drop of the page cache of the host with PAGE_CACHE_DROP. A failure is an error. | | startBallast(bytes, options) | From /fresh: a second Node process that holds a resident set of a given size, and stops with its parent. | | processIo(options) | From /fresh: one read of the disk counters, the major faults, the resident set and the cgroup counters of this process. | | watchIo(intervalMs, options) | From /fresh: the samples of processIo at an interval, from a worker thread. | | checkoutArm(options) | From /fresh: an arm on a git worktree of a commit, built by its setup commands. | | repoCommit(ref, options) | From /fresh: the full hash of the commit of a ref, for the arm of the job. | | eventProbe(options) | From /fresh: the GC events, the GC time and the deopts of a child in each half of its counted samples. | | caseWarms(records, arm) | The median warm check of each case over its rounds, for one arm of the records. | | warmVerdict(pairs, options) | The warm rule of a fresh run: each pair against the A/A pair, and the steady cases. | | pairedChild(options) | The samples of one paired child: the base, the candidate and a copy of the base in one process, in turn. | | pairedChildOrder(round, offset, steps) | The order of the samples of a paired child: a block A B B A for each pair at each step. | | childRecords(case, round, offset, order, times) | The PairedTime of the candidate pair and of the A/A pair of a paired child, from the medians. | | codeStamp(options) | From /code-stamp: the stamp of the code of a run, from the code that its entries reach, the lock closure of its engines and its data files. | | lockClosure(text, importer, names) | From /code-stamp: each package that an engine pulls in, from a pnpm lock file. | | configStamp(root, config) | From /stamp-gate: the stamp of the timed code of a bench in a checkout, from a config file. | | stampChanges(base, head) | From /stamp-gate: the parts of two stamp records that differ. No part means the same timed code. | | stampCli(argv, io) | From /stamp-gate: the command of the bin rigor-stamp. | | superviseCases(options) | From /supervise: each case in a child process, held to a time budget, with a hard stop and a resume. | | caseProgress(file) | From /supervise: the writer of the progress file of a child. | | startSupervisedProcess(argv, options) | From /supervise: a child process that superviseCases can stop with its tree. |

A claim with a limit

timeVerdict compares the ratio with 1. A claim with a limit needs limitVerdict. An example is "the new code takes at most 2 times the time of the old code":

const v = limitVerdict(records, aaRecords, { limit: 2 });

v.outcome;                                        // "within", "beyond" or "cannot decide"
v.cases;                                          // the interval, the bound and the outcome of each case
  • The A/A band widens the interval of each case. The bound is the high end of the interval times the high end of the band.
  • A case is within when its bound is at most the limit. It is beyond when its low end times the low end of the band is above the limit.
  • The verdict is beyond when a case is beyond, and within when each case is within.
  • The option share permits some cases out of the limit. With share: 0.95 and 20 cases, 1 case can be other than within. The verdict is within when that number of cases or fewer are other than within. It is beyond when more cases are beyond. The field allowed gives the number.

The band of the A/A arm needs 5 A/A cases or more. A bench with fewer cases gives aaFrom: "rounds":

const v = limitVerdict(records, aaRecords, { limit: 1.1, aaFrom: "rounds" });
  • The A/A rounds of each case give the noise of that case. The noise is the larger distance from 0 of an end of the interval of the A/A median, on a log scale.
  • A case with no A/A rounds cannot decide. The verdict has no band, and the field noise of each case gives its noise.

A wide A/A arm widens each bound, but a case far below the limit can still pass on a noisy run. The option noiseCap stops this:

const v = limitVerdict(records, aaRecords, { limit: 1.1, aaFrom: "rounds", noiseCap: 0.05 });
v.cases.map((c) => c.noiseCheck);                 // the spread, the A/A median and the flags of each case
  • With aaFrom: "rounds", the spread of a case is the spreadLevel quantile of abs(log(b / a)) over its A/A rounds, as aaStats gives it.
  • With the A/A noise of the cases, each case has the spread of the A/A arm, as aaSpread gives it.
  • A spread above the cap makes the case cannot decide. An A/A median ratio out of [exp(-noiseCap), exp(noiseCap)] does too.
  • Take the cap from the A/A spreads of earlier quiet runs, for example with aaLimits.

The verdict has no correction for many cases. Each case has its own interval at the level caseLevel. Thus with many cases, a verdict beyond can come from noise only. Set caseLevel higher when a bench has many cases. A correction of Holm is an option for a later version.

A claim on a slope

A claim, for example "the walk takes time linear in the size", needs a ladder of sizes. One ratio of two sizes cannot tell a constant factor from a power. slopeVerdict reads rounds of 3 rungs or more:

const rounds = [{ run: "job-0", rungs: [{ size: 1000, value: 2.1 }, { size: 2000, value: 4.3 }, { size: 4000, value: 8.4 }], aa: 1.01 }];
const v = slopeVerdict(rounds, { limit: 1.2, holds: 1, band: 0.05 });
  • roundSlope fits the slope of log value against log size in each round. A linear cost gives 1, and a square cost gives 2.
  • aa is the ratio of a second copy of one rung to the first copy, in the same passes. A run counts only when its A/A band contains 1.
  • The interval of the slopes reads the rounds of the counted runs. The default "spread" is the 5th to the 95th percentile. interval: "median" gives the interval of the median slope.
  • The outcome is within when the high end is at most limit. With holds, the interval must also meet the band holds plus or minus band.
  • The outcome is beyond when the low end is above limit, or when the interval is outside that band. gateOf reads the outcome.
  • The claim "at most linear" gives only limit. Then a slope well under 1, from a large fixed part of a call, also passes.
  • growthVerdict reads the growth of each step of size in each job, with no A/A check. Use it when one step can grow faster than the others. slopeVerdict fits one power over all rungs.

A claim with a limit on a tail

limitVerdict needs an interval of the median, and a few rounds give a wide interval. tailLimitVerdict reads each value as it is. An example is a gate with 7 rounds and one limit for each module:

const v = tailLimitVerdict(records, aaRecords, {
  limit: (name) => limits[name],
  aaCap: 1.3,
});
v.outcome;                                        // "within", "beyond" or "cannot decide"
v.aaTail;                                         // the largest tail of the A/A arm

The rule of the verdict:

  • The tail of a case is the value at rank of its ratios, from the largest. The default rank is 2, so one slow process cannot move it.
  • A case is beyond when its median is over limit.median.
  • A case is also beyond when its tail is over limit.tail and over the largest tail of the A/A arm of the run.
  • Each case is cannot decide when the largest tail of the A/A arm is over aaCap. A loud run has no power, and this is not a pass. The caller takes another read.
  • The option aaCap has no default, because a run with no cap passes each row when it is loud.
  • The option expected names the cases that the run must have. A case of that list with no record reads cannot decide. Without this option, a run that loses a case reads the other cases only.
  • gateOf(v.cases) gives the gate of the verdict: pass, block or no read.

With the default rank, a real cost in 1 round cannot fail the tail limit. This is by design: of 7 rounds, 1 round passes the tail, because 1 round cannot be told from noise. A cost in 2 rounds or more can fail it.

The verdict has no interval, so a limit needs a margin from the spread of earlier runs. tailFalseFails applies the rule to each case of an A/A arm. Each case reads the tail of the other cases. Print the count of fails on the gate, to state what the rule costs on noise.

A limit under 1 states a gain, and an A/A pair shows no gain. So the A/A arm has no read of that case, and the case goes in gains with that reason. The false fails of a gain limit come from repeat reads of an unchanged tree against its fixed base.

A verdict over k processes

Each fresh process of Node.js is one sample, because each user gets one process. A gate script can time each case in a process. It gives one ratio and the A/A band of the process. processVerdict decides each case over its first k valid processes:

const limits = cpuEntry({ "7763": { limit: 1.1, slow: 1.2, maxSlow: 2 }, other: { limit: 1.2, slow: 1.3, maxSlow: 2 } }, cpu);
const v = processVerdict(reads, { k: 7, limits: limits.value });
v.outcome;                                        // "pass", "block" or "no read"
v.more;                                           // the processes to start before the next read
v.cases.map(processCaseLine);                     // one line for each case

The rule of the verdict:

  • A read is { process, case, ratio, aa, fault }. A process counts for a case only when its A/A band contains 1.
  • With noiseCap in the limits, a process counts only when readNoise of its band is at most the cap. Else it is noisy. A read with no band is then noisy too.
  • A noisy run cannot decide. A case with too many noisy processes is cannot decide, and the gate gives no read. Take the cap from the A/A noise of earlier quiet runs.
  • Check (a): the median of the first k valid ratios is at most limit.
  • Check (b): the count of these ratios above slow is at most maxSlow. Without maxSlow, the count is a record only.
  • A case with a fault is beyond. A case with no read from a process of the option processes is cannot decide.
  • With fewer than k valid processes, a case is cannot decide. Then more gives the count that it needs.
  • A case that fails a check for each value of the other processes is beyond at once.

Check (b) is the tail rule of tailLimitVerdict with the rank maxSlow + 1. With slow equal to limit and maxSlow 0, check (b) is "the worst ratio is at most the limit". Thus a read can also be the median ratio of one job, and the verdict reads k jobs. Take each limit from earlier runs with runLimit.

The noise cap from earlier jobs

processNoiseCap gives the cap of one case from the reads of 5 or more earlier jobs. The noise of a case changes with the CPU model. So give it the reads of one case on one model:

const c = processNoiseCap(jobs, { k: 11 });       // jobs: [{ job: "134957202670", reads: [...] }, ...]
if (c.source === "jobs") {
  c.cap;                                          // the noiseCap of the limits
  c.quantile;                                     // the 0.95 quantile of the read noise, with its interval
  c.decideRate;                                   // the chance that a quiet run decides at the cap
}
  • A job whose median read noise has a robust z-score above 3.5 is not quiet. The result names it in dropped.
  • The cap is the 0.95 quantile of the read noise of the quiet jobs, rounded up. So a quiet read passes the cap 95% of the time.
  • The decide rate is the chance of at least k valid reads in 2k processes, for each quiet job. A gate test can refuse a cap with a decide rate under 0.95.
  • The reads of one job share one runner. So the bootstrap interval draws whole jobs.
  • With fewer than 5 quiet jobs, the result has no cap: its source is too few.

The limits from earlier jobs

processLimits gives the limits of one case from the reads of 5 or more earlier jobs. Keep the limits of a gate as data, and let a test give them again from the jobs:

const fit = processLimits(jobs, { k: 11, digits: 2 }); // jobs: the reads of one case on one CPU model
if (fit.source === "jobs") {
  fit.limits;                                          // { limit, slow, maxSlow }: the limits of processVerdict
  fit.median;                                          // runLimit of the job medians: the worst, the spread, the values
  fit.slow;                                            // the slow reads, their Wilson interval and the chance at maxSlow
}
  • The median of a job is the median of its first k valid reads, as processVerdict takes them. With noiseCap, a noisy read is not valid.
  • The limit is runLimit of the job medians: the worst median plus their spread, rounded up. The slow line is the limit.
  • The slow rate is the upper end of the Wilson interval of the share of the used reads above the limit.
  • maxSlow is the smallest count with P(Binomial(k, slow rate) > count) under risk. The default risk is 0.01.
  • With fewer than 5 jobs, the result has no limits: its source is too few.

A read of each CPU model

Runners of one label have different CPU models. A check of the pool passes when most reads come from the other models, so it can hide a model that reads apart. modelTest reads each model against the rest of its case. It uses a two-sample permutation test of the median, with one Holm family over all the rows.

  • differs: the adjusted p is under alpha, and the shift is at resolution or more, when the caller gives one.
  • no read: the test finds no difference. Few reads have little power, so this does not say that the model is the same. The row gives floor, the smallest p of that count, and level, the first level of Holm in the family. When floor is over level, the words of modelRowText say that this size cannot reach the level, with no flip. A row of that size reads differs only if other rows read differs before it, because each of those rows raises the level. When the level is in reach, visible gives the smallest shift that this test can see at that count and family. The option searchVisible set to false stops only that search.
  • too-few: the model has under minReads reads, or the case has no other model. The row keeps its facts, and it stays out of the family.
  • not asked: the option asked leaves the row out of the question. State the question before the reads, because a family that is chosen after a read has no valid p.

A read of differs tells where to look. It does not name a cause, because the reads of one model can share a runner image and a date.

limitOnModel gives the limit of a gain that reads on some models only. A model with no earlier reads gets the ceiling, and its read carries the words of CEILING_ONLY. A pass at the ceiling stops a loss, and it does not hold the gain.

cpuEntry gives the entry of a table for a CPU name, for example the limits of each model. The key is a part of the name, and the case of the letters does not count. A name with no key gets the entry other.

armModels reads the models of the two arms of a set of pairs. When the arms come from different computers, a ratio compares the computers. A record with no model reads as unknown, and unknown is not one known model.

A frozen limit on each CPU model

A measure, for example a p99 time, has no base arm in a PR job. So its gate compares the read with a limit from earlier reads on the same CPU model.

  • candidateLimits gives the mean of the reads of each model plus noiseFloor of @mark1russell7/rigor-statistics. The default rule MODEL_LIMIT_RULE is 3 standard deviations from 5 reads or more.
  • A model with too few reads, with equal reads or with no known model gets no limit.
  • freezeLimits writes the limits as data, with their values, the commit and the date. checkModelLimits computes each limit again, so the next reader can verify it.
  • modelLimitRead gives no read for a model with no frozen limit. A no read is not a pass.

A limit does not move by itself. When new reads go straight into the limit, a slow regression raises its own limit. So a nightly run gives only a candidate, and a change of the file goes through a pull request. limitChanges accepts a tighter limit, a new model and a removed model. It refuses a looser limit that has no new reason, for example a change of the runner image. It also refuses a change of the rule or of the measure with no new ruleReason.

The limits of a gate from earlier runs

The rule of the gate limits: a limit is the worst value of 5 or more CI runs plus their spread (max - min), with no factor. runLimit gives it:

import { aaLimitOf, aaLimits, aaStats, runLimit, timeVerdict } from "@mark1russell7/rigor-bench";

runLimit([1.31, 1.38, 1.37, 1.38, 1.31]).limit; // 1.45: the worst value 1.38 plus the spread 0.07

const limits = aaLimits(
  jobs.map((job) => ({ job: job.job, cases: aaStats(job.aa) })),
  { family: familyOf, marginFloor: Math.log(1.015) },
);
const { margin, noiseCap } = aaLimitOf(limits, familyOf(name));
const verdict = timeVerdict(candidate, aa, { margin, noiseCap });
  • The limit goes away from the values at its last digit, so each run of the limit stays inside it. A measure where higher is better takes better: "higher".
  • aaStats gives the A/A statistics of each case in one job: the median of log(b / a) over the rounds, and the 0.9 quantile of abs(log(b / a)).
  • For each family, each job gives its worst abs(median) and its worst spread over the cases of the family. The margin and the noise cap are runLimit over the jobs.
  • A job whose worst spread is far above the other jobs goes out. The test is the robust z-score of rigor-statistics above 3.5, on the high side. The result names each job that went out.
  • A family with fewer than 5 jobs uses the fallback limits of all cases. Fewer than 5 jobs for the fallback limits is an error.
  • Keep the A/A statistics of the jobs next to the limits. A later run then gives the limits again and compares them.

A gate that can fail

A check that blocks a merge needs a result that can fail. gateOf reads the case outcomes of a verdict, and notSlowerVerdict gives the claim of a speed gate.

const gate = notSlowerVerdict(jobs, { margin: Math.log(1.015) });

gate.outcome;                                     // "pass", "block" or "no read"
gate.cases;                                       // "not slower", "slower" or "no read" for each case, with the facts of each job
gate.more;                                        // the next look of each case with no outcome
  • The claim is "not slower by more than the margin". A one-sided bound answers it, thus a case can read not slower when its interval holds 1. The word same of timeVerdict asks for more.
  • The outcome of each case uses the words of LimitOutcome: within is not slower, beyond is slower, and cannot decide is no read. Thus gateOf also reads limitVerdict and budgetVerdict.
  • A case needs its bound in each of jobs jobs, by default 2. More rounds do not remove a difference between jobs.
  • The claim "the bound holds in at least r of J jobs" is a partial conjunction. Its p is (J - r + 1) times the r-th smallest p of the jobs (Benjamini and Heller, 2008). With 2 jobs of 2, this p is the larger p.
  • The sign test compares the median difference with the margin in each job. It uses no random numbers.
  • A pair holds two records with the same first arm. A runner can give the two arms opposite orders in one round, and a difference of two orders holds the effect of the order.
  • The level is for the family. holm corrects each look over all cases. Each look has an equal share of the level.
  • The first look with an outcome decides a case. GATE_LOOKS is 12, 24 and 48 rounds.
  • Take 16 cases and the default looks. The first test of a family at 12 rounds needs 12 of 12 pairs below the margin in both jobs. Thus a noisy case needs more rounds, or it stays no read.
  • no read is not a pass. A caller adds the rounds of more, then more jobs. A job that it adds after the last look is one more look, and the level does not count it.

The level needs independent rounds. Rounds with a shared cause, for example a slow computer for one job, do not have it.

A hold that a record accepts

A gate that blocks a merge holds it. The summary check fails under the hold, unless the pull request has a record that accepts the cost of each slower case.

const hold = holdGate(gate, heads, readHoldAcceptances("bench/accepted"));

hold.outcome;                                     // "pass", "held", "accepted" or "no read"
hold.lines;                                       // one line for each slower case, and one for each fault of the records
holdVerdictWord(hold.outcome);                    // "pass", "block" or "no-read" for the verdict file
  • A record is { "case", "head", "cost", "reason", "owner" }, in a JSON list. Each field is a text that is not empty.
  • The field head has 12 to 64 characters of the hash of the head arm, in lower case. heads gives the hash of the head arm of each run.
  • A record matches only when each run has the same head arm, and its hash starts with the hash of the record. Thus a record accepts nothing after the code changes, and runs of two heads accept nothing.
  • Each slower case needs its own record. A record for another case or another head does not count.
  • A file with one record that is not valid gives no read, also when the gate passes. no read is not a pass.
  • The first form of this gate is K239 of coeval.

Show a gate read on the check

A block or a no-read that shows only in a table of the summary is easy to miss. A no-read is not a pass. gateLine gives one line for the check of the run, and writeGateLine writes it.

const line = gateLine(cases, { title: "evaluator bench", enforced: false, models: armModels(pairs) });
writeGateLine(line);   // a ::warning annotation (::error when enforced), and a line of the file of GITHUB_STEP_SUMMARY
  • The input is a list of { case, outcome }. The cases of limitVerdict and budgetVerdict have this form. Give one entry for each timeVerdict.
  • The outcomes cannot decide and no read are no-reads, and isNoRead tells them. The outcomes beyond and slower are blocks, and isBlock tells them.
  • When each case passed, the line is undefined and writeGateLine writes nothing.
  • An empty list gives a line, because gateOf gives no read for it.
  • One line names the blocks and the no-reads, each with its count and the names of its cases.
    • The line names at most GATE_LINE_NAMES (10) cases of each kind, then "and 15 more". The counts are exact.
    • blocks.cases and noReads.cases keep each case. Only the text names fewer cases.
    • The text has at most GATE_LINE_LIMIT (4096) characters. A case name of more than 120 characters ends with an ellipsis in the text.
    • The Checks API of GitHub limits the message of an annotation to 64 KB and its title to 255 characters. The documents of the workflow commands give no limit. Thus 4096 is a conservative limit.
  • The outcome of the line is block when a case blocks, else no read, as in gateOf.
  • The level is error when enforced is true. The default is warning, for a read that only reports. The title of a read that only reports says so.
  • With reason, the line tells the reason after the counts, for example "a decision needs 3 jobs, not 2".
  • With models, the line names the CPU models. Give one of two forms, not both.
    • An ArmModels of armModels names the models of the two arms. The line tells a mixed pair, because a ratio can then compare two computers.
    • A list of { model, jobs } names each model and its count of jobs, for a time budget with its ratios inside one job. The line makes no claim about the ratios. The line is mixed when the jobs are on more than one model.
    • jobModels(envs) gives this list from the computer of each job: the count of the jobs on each CPU model, sorted by model.
    • jobModels(envs, { cores: true }) also keeps the count of the cores. Each model and count of cores has an entry, and the line names the cores: "AMD EPYC 7763 with 4 cores (2 jobs)".
    • Without the option cores, the entries and the text do not change.
    • An empty list gives the sentence "The jobs have no CPU model".
  • Write the line also when the run is report only, so its check shows the read.
  • writeGateLine writes the annotation to the standard output. With stream: "stderr", it writes to the standard error. GitHub Actions reads the annotation from the two streams.

A gate line from a shell step

The bin rigor-gate-line writes a gate line from a JSON document. A shell step uses it when the reads are in a file.

rigor-gate-line --from gate.json                  # the annotation on stdout, and a line of GITHUB_STEP_SUMMARY
rigor-gate-line --stream stderr < gate.json        # the document from stdin, the annotation on stderr
rigor-gate-line --from gate.json --summary own.md  # a summary file that is not GITHUB_STEP_SUMMARY
{
  "reads": [{ "case": "read-1", "outcome": "beyond" }, { "case": "read-10", "outcome": "cannot decide" }],
  "options": { "title": "store gate", "enforced": false, "reason": "too few rounds" },
  "jobs": [{ "cpu": "AMD EPYC 7763", "cores": 4 }],
  "cores": true
}
  • reads and options are the two arguments of gateLine. options.models takes the two forms of models.
  • jobs gives the models with jobModels when options has no models. With "cores": true, the line names the cores.
  • The exit code is 0 for a line and for no line. The line informs, and the step decides its own exit.
  • An enforced read adds its verdict to the verdict file of the job: --verdict <file>, or the variable GATE_VERDICT_FILE. A read that only reports adds no verdict.
  • A bad argument or a bad document gives the exit code 2, with the reason on stderr.
  • gateLineCli(argv, io) is the same command as a function, for a test or a script of its own.

The verdict file of a gate job

The reusable gate workflow of mark1russell7/template gives a gate job a second try on a fresh runner after a no read. It reads one verdict line for each gate from the file GATE_VERDICT_FILE.

const gate = gateOf(cases);
writeGateLine(gateLine(cases, { title: "compiler gate", enforced: true }));
writeGateVerdict(gate.outcome); // "pass", "block" or "no-read" as one line of GATE_VERDICT_FILE
  • The word of no read is no-read. The other words are the outcomes of gateOf.
  • Each gate of the job adds its own line. The workflow reads all the lines: a block decides first, then a no read.
  • Without the variable, writeGateVerdict writes nothing and gives undefined. A local run then has no file.
  • Write the verdict of each gate that decides the check. A read that only reports writes no verdict.

A claim with a budget

limitVerdict judges a ratio of two arms. A budget is an absolute limit on one build. An example is "the median blocking time of this page is at most 450 ms". A budget needs budgetVerdict:

const v = budgetVerdict(rounds, aaRounds, { limit: 450, maxDifference: 200 });

v.outcome;                                        // "within", "beyond" or "cannot decide"
v.cases;                                          // the medians, the interval, the outcome and the reason of each case
  • Each round has the fields case, round and value. A value of 0 is valid, so a case with no blocking time has a verdict.
  • The arm aa is a second arm of the same build. When the two medians differ by more than maxDifference, the run is too noisy, and the case is cannot decide.
  • This check uses a difference, not a ratio. Two medians of 249 and 102 are a healthy run with a ratio of 2.4.
  • The level 0.95 needs 6 rounds or more in each arm. With fewer rounds, the case is cannot decide.
  • A case is within when the high end of the interval of its median is at most the limit. A case is beyond when the low end is above the limit.

Add rounds up to a budget

Six rounds give an interval from the lowest to the highest value. One slow load makes the case cannot decide, and a rerun hides this. budgetLooksVerdict adds rounds to the cases with no outcome:

let v = budgetLooksVerdict(rounds, aaRounds, { limit: 450, maxDifference: 200 });
while (v.more.length > 0) {
  // Add rounds to both arms, so each case in v.more has its v.more[i].rounds.
  v = budgetLooksVerdict(rounds, aaRounds, { limit: 450, maxDifference: 200 });
}

v.fails;                                          // true only when an interval is above the limit
  • BUDGET_LOOKS has looks at 6, 12 and 24 rounds. The interval of 6 rounds is the same as in budgetVerdict.
  • Each extra look at the data adds a chance of error. The levels of the looks are high, so the sum of the chances is 0.0442, under the overall 0.05.
  • The sum comes from the real coverage of each interval, not from the nominal level. A list that spends more than the overall level gives a RangeError.
  • Each coverage needs independent rounds. This limit stays: a slow computer for one whole run moves all its rounds.
  • The first look with an outcome decides a case. Later rounds of the case do not change it.
  • A final cannot decide does not fail. Show it to the reader of the run. A median near the limit can have this outcome.

We tested the default looks by resampling 48 blocking times of a noisy web page, with the median moved. Each row has 20000 seeded runs, and the limit is 450.

| True median | Six rounds: outcome beyond | Looks: outcome beyond | Looks: final cannot decide | Mean rounds | | ---: | ---: | ---: | ---: | ---: | | 300 | 0% | 0% | 0% | 6.9 | | 376 | 0% | 0% | 2.8% | 12.4 | | 450 | 1.5% | 2.0% | 96.1% | 23.4 | | 500 | 38.6% | 89.0% | 11.0% | 15.1 | | 550 | 44.6% | 93.9% | 6.1% | 13.8 |

A claim at each size: the ladder

A ladder is the scale plan of a product, as data. It has rungs at sizes that grow, for example 1, 10 and 100 tenants. Each rung has budgets, and it names the test that holds it. A number in a document is not a rung: a rung is held only when a record of its test shows each budget within.

const ladder: Ladder = {
  format: LADDER_FORMAT,
  subject: "reference service",
  dimensions: [{ name: "tenants", describe: "one customer" }],
  rungs: [{
    name: "1,000 tenants",
    at: { tenants: 1000 },
    test: "load-1000",
    locked: true,
    budgets: [
      { kind: "median", measure: "read", unit: "ms", limit: 50, maxDifference: 20 },
      { kind: "rate", measure: "failed requests", limit: 0.0001 },
      { kind: "worst", measure: "lost writes", unit: "writes", limit: 0, minDrills: 3 },
    ],
  }],
};

const v = ladderVerdict(ladder, records, { now: new Date().toISOString(), maxAgeDays: 8 });

v.held;                                           // the highest rung with each rung up to it within
v.next;                                           // the first rung that is not within
v.failed;                                         // true when a locked rung is not within

There are four kinds of budget:

| Kind | Evidence | The verdict | | --- | --- | --- | | median | Rounds and an A/A arm | budgetVerdict, so the rules of a budget apply. | | quantile | The values, and optional censored bounds | The distribution-free interval of the quantile at 95 % against the limit. | | rate | Failures and trials | The Wilson interval at 95 % against the limit. | | worst | The value of each drill | The largest value against the limit. One bad drill is beyond. |

  • 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.
  • 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.
  • 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 %.
  • A locked rung fails when it is beyond and when it is cannot decide. A skipped test is not a pass.
  • 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.
  • A high rung does not count over a gap: held stops at the first rung that is not within.
  • A record states what was real and what was synthetic. A record with no entry in real gives cannot decide.
  • checkLadder gives each problem of a ladder as data. ladderVerdict throws a RangeError for a ladder with problems.

A claim on the growth of a cost

A ladder holds each size to a limit. A growth claim holds the step between sizes, for example "the time of one publish grows less than 15 times for each 10 times more subscribers". A cost that grows as n x n grows 100 times for each 10 times. A linear cost grows 10 times.

const v = growthVerdict(
  [
    { job: "job-1", size: 1_000, value: 9.0 },
    { job: "job-1", size: 10_000, value: 51.8 },
    { job: "job-1", size: 100_000, value: 590 },
    // ... the same sizes for each other job
  ],
  { maxGrowth: 15 },
);

v.outcome;                  // "within", "beyond" or "cannot decide"
v.steps[0].median;          // the median growth of the jobs from 1,000 to 10,000, for a step of 10 times
v.steps[0].exponent;        // the cost grows as the size to this power
  • The verdict reads a ratio inside each job: the cost at the larger size over the cost at the smaller size. Each job runs on one runner, so a slow runner changes both values and the ratio keeps its value. The verdict needs no A/A arm.
  • A step that is not per times in size is scaled to per times, with the exponent of the step. The default of per is 10.
  • The interval of each step is the distribution-free interval of the median of the jobs. With 5 jobs it is the full range, with the coverage 0.94. A step is within when the high end is less than maxGrowth.
  • A job that gives more than one value at a size gives their median.
  • The flip test of a growth gate is the old code: it must give beyond.

The cost of a run before it starts

A run with a time budget stops a case when the budget ends. A plan of a run needs its cost before the start. runCost gives this cost from the cells that the run measures and from probes of one call.

const cost = runCost(
  [
    { job: "shelf", size: 100, cells: 40 },   // only the cells that the run measures
    { job: "shelf", size: 1_000, cells: 40 },
  ],
  [
    { job: "shelf", size: 100, model: "cpu-a", ms: 2 },     // probes of the same inputs
    { job: "shelf", size: 1_000, model: "cpu-a", ms: 30 },
  ],
  { calls: 7, overhead: 1.45, budgets: [{ upTo: 10_000, ms: 60_000 }] },
);

cost.models[0].minutes;              // the minutes of the bench step on cpu-a
cost.models[0].jobs[0].stopsAt;      // the size where the job stops on its overruns, or undefined
cost.low; cost.high;                 // the range over the CPU models
  • Give only the cells that the run measures. A cell that a job does not support at its size is not a cell. A count of all the cells of a corpus can be 4 times too large.
  • Probe the same inputs that the run measures, on each CPU model. Times of other inputs can be 1.6 to 28 times off, also on one model.
  • A size between two probe sizes gets a time on the line of the log scales. extrapolated names each size outside the probe sizes.
  • More probes of one size give their mean, because a sum over cells follows the mean. The size 0 is not on the line.
  • calls is the count of the warmup starts and the timed starts of one cell. slow gives a slow cell its own count.
  • The probes of the nearest probe size give the spread of the times at a size. A cell over its budget costs the budget.
  • When the expected count of the cells over budget at a size gets to overruns, the job stops. The counts of cells are expected counts.
  • overhead is the bench step minutes over the call minutes of an earlier run. jobMinutes adds the fixed minutes of each job.

Time the rounds

timeRounds times one case in one process. Start a fresh process for each case and each pair, and give the index of the case as offset:

const { records } = timeRounds({ a: () => oldCode(input), b: () => newCode(input) }, { case: "board-1", rounds: 31, offset: 0 });

Each arm gives a number. The engine cannot remove the work of a call, because the sum of these numbers uses it.

More than two arms in one process

timeArmRounds times a base and 1 or more candidates of one case in one process. The records have the form of a fresh run:

const run = timeArmRounds({
  case: "board-1",
  base: { id: "loops", run: () => loops(input) },
  candidates: [{ id: "engine", run: () => engine(input) }],
  rounds: 16,
});
const verdicts = armVerdicts(run, "loops~aa");
  • Each candidate makes a pair with the base. The id of the pair is the id of the candidate.
  • The A/A pair <base>~aa times the base a second time in each round. aa: false removes it.
  • A function in aa is the second arm of the A/A pair. Give it a second copy of the code of the base.
  • Two builds in one process are two modules. Two modules of the same code can differ in time, and the base a second time does not show it.
  • In ESM, a query on the URL of a file gives a second module of the file: import(new URL("?copy=aa", url).href). Its imports stay shared.
  • Each round times one batch of each arm in the order of armOrder. Thus each pair has each order one time in each two rounds.
  • offset turns the arms before armOrder. Give the index of the case, so the cases start with different arms.
  • Each pair of a round uses the one base batch of that round. orders has the order of the batches of each round.
  • The count of calls of a batch grows until a batch of the base takes targetMs. Each arm uses that count.
  • warmBatches adds untimed batches of each arm before its timed batch, in each round. No batch of another arm comes between them. The default is 0.
  • spans keeps the start and the end of each timed batch, in the layout of orders. The clock now also times the warm-up and the calibration. Thus a record of the marks of the clock uses spans to find the timed batches.

Time one arm in a child

timeArm is the child side of freshRun. Each child times only its own arm, and prints one JSON line:

import { timeArm } from "@mark1russell7/rigor-bench";

const time = timeArm(() => kernel(input), { samples: 15 });
console.log(JSON.stringify({ ms: time.ms, calls: time.calls }));
  • The arm first operates for the warm-up time warmMs. Then the calls of one sample double until a sample takes targetMs.
  • After warmSamples samples that do not count, the function times samples samples. ms is the median time of one call.
  • Give calls of an earlier process. Then the function does not calibrate, and each process does the same work.
  • A flip test gives slow, for example 1.05. Each sample then waits in the timed part, so the timer reads a real slowdown of 5 %.
  • The module keeps the value of each call. Thus the engine cannot remove the work of a call.
  • With 2 samples or more, warm is the median of the last half of the samples over the median of the first half. A value near 1 tells that the arm was warm.

A child line can also give its memory peak, its warm check and its events. freshRun keeps them in the field fields of each record:

import { timeArm } from "@mark1russell7/rigor-bench";
import { eventProbe, peakRss } from "@mark1russell7/rigor-bench/fresh";

const probe = eventProbe({ deopt: true });
const time = timeArm(() => kernel(input), { samples: 16, mark: probe.mark });
console.log(JSON.stringify({ ms: time.ms, warm: time.warm, peakRss: peakRss(), events: await probe.events(16) }));
  • events.gc and events.deopt each have two counts: the first half and the last half of the counted samples.
  • events.gcMs has the GC time of each half in milliseconds: the sum of the durations of the GC events that start in the half.
  • events.gcMaxMs has the longest GC event of each half in milliseconds. A half with no GC event has 0.
  • A long block of the event loop can be one GC event. Compare the block with gcMaxMs, not with the mean of gcMs.
  • The probe counts the deopts only with deopt: true. Then the V8 flag --trace-deopt writes them to a temporary file.
  • childLine refuses a field that is not valid. A record has fields only when a child of the record gives a field.
  • A time line keeps each other field in fields.extra, with its JSON value. An example is the samples of a child, or its batch. The runner does not examine them.

The warm rule

A child whose time goes down while it counts was not warm. warmVerdict compares the warm checks of each pair with the A/A pair:

import { aaBand, warmVerdict } from "@mark1russell7/rigor-bench";

const aa = "base~aa";
const band = aaBand(run.pairs[aa], { kind: "case", level: 0.8 });
const warm = warmVerdict(run.pairs, { aa, band });
warm.arms.next; // { cases: 40, median: 1.0, p10: 0.97, p90: 1.04, outside: 0.15, ok: true }
  • The warm value of a case is the median warm check of the arm b of the pair over the rounds of the case.
  • A pair is warm when its share of cases outside the band is at most the share of the A/A pair plus slack. Its median warm value must also be in median.
  • The defaults are slack: 0.1 and median: [0.97, 1.03]. A fixed limit on the share fails, because the A/A pair also has cases outside.
  • steady lists the cases with each pair and the A/A pair in the band. A time gate can read only these cases.
  • A pair with no warm check is an error. Thus a rule that cannot read a pair does not pass.

Drop the second run of a slow case

A bench can run each case two times. The second run tells if the result stays the same. A slow case can drop its second run to save time. Then that case has no read of the same result. Each bench states if it keeps the second run.

const sentinels = new Set(sentinelCases(lastTimes, { limitMs: 60_000, seed: "2026-11-15" }).map((s) => s.key));
const method = runMethod(first.ms, { limitMs: 60_000, sentinel: sentinels.has(key) });
const second = method === "one run" ? undefined : run(key);
const same = sameResult(method, first.hash, second?.hash);
  • overLimit reads a time over the limit, not equal to it. With no limit, each case keeps its second run.
  • Each record states its method. A case with one run has null as its claim of the same result. It is not true.
  • sentinelCases keeps the check live on the slow cases. The case over the limit with the smallest time keeps its second run.
  • Each group with a case over the limit also gets one rotating sentinel, chosen with stablePick under the seed and the name of the group. A new seed for each run turns it.
  • The times of sentinelCases can come from an earlier run, because the choice comes before the first run.
  • firstAgainstSecond gives the ratio of the second time over the first time for each group, from the cases with two runs.
  • A median under 1 tells that the second run is faster. Then a time of the first run alone is another measure, and a page that quotes it says so.

Read the load of a run from a control

Runs on shared machines differ by load. A control is a case that a change does not touch, so its time measures the machine. controlFactor gives the load factor of each group of rows.

import { controlFactor } from "@mark1russell7/rigor-bench";

// Two runs: the median ratio of the keys that both runs have.
const two = controlFactor(rows, { base: "run-1" });
two.factors[0]; // { group: "run-2", factor: 1.35, pairs: 200, low: 1.2, high: 1.5, censored: 3 }

// One run, grouped by shard: each time against the median of its key over the shards.
const shards = controlFactor(shardRows);
  • A key names a class of work, so equal keys in two groups mean equal work. Thus a shard with a different mix of work does not read as load. Each group has at most one row for a key.
  • A key in one group has nothing to compare with, so no factor reads it. The field unshared counts those keys.
  • Without base, a factor reads against the other groups. Thus a load that all groups share does not show.
  • A group with too few usable keys gets an entry with factor undefined and a reason, so the other groups keep their factors. The function refuses a result where no group has a factor.
  • A censored time is only a lower limit, so no ratio reads it. The field censored counts those keys. A run stops its slowest cases, so a factor reads low when censored is not 0.
  • The fields low and high are the quartiles of the ratios. A wide spread means that one factor does not explain the load.
  • The function refuses a group with fewer usable keys than minPairs. The default is 5.

Check that a trick does not buy a measure

A control is a strategy made to win one measure and nothing else. A real entry can win that measure by the same trick. So checkMeasures reads the controls of a bench, and winClaim tells a page what to show beside a win. Each project keeps its own controls.

import { checkMeasures, winClaim } from "@mark1russell7/rigor-bench";

const check = checkMeasures(rows, {
  asOf: "2026-11-05",
  controls: ["only-fill"],
  rules: [
    { measure: "fill", sense: "higher", controls: ["only-fill"], partners: ["order"] },
    { measure: "order", sense: "lower", controls: [], partners: [], noControl: { because: "The control has no code yet.", until: "2026-11-20" } },
  ],
});
if (check.findings.length > 0) process.exitCode = 1;
const claim = winClaim(check, "fill", "my-entry");

Each row has a measure, a group, a key and a value. The optional fields are censored, method and stratum. The function throws a RangeError for a repeat of a measure, a group and a key. The caller states how repeats reduce to one row.

  • Beats: the Holm-corrected sign test passes. With a resolution, the median paired difference is also over it. Without one, the output says test only.
  • Floors: a rule can state floors, one number for each group. The noise of a measure can differ by group, so one number for all groups removes real gains or passes noise. A comparison then needs a size over the larger floor of its two groups, and floor gives that size. A group with no floor reads resolution. A group with neither makes the check throw.
  • A control wins when no real entry beats it. A tie counts for the control.
  • A control loses a partner when one real entry beats it on that partner, at the level divided by the count of partners. One passed partner clears uncaught, so each partner is one more chance.
  • The median of a partner: each partner read also gives beatenBy of of. beatenBy counts the real entries that beat the control on that partner at the same level. of counts the real entries with a read. excluded counts the real entries with too few untied keys for a read. A small of with a large excluded reads few entries, so read the two counts together. caught is true only when beatenBy is over half of of, so the median real entry beats the control. One outlier entry can make the status lost, but it cannot make caught true. No finding reads caught.
  • Families: one Holm family holds one control on one measure, over all real entries and all strata. A second family holds the same tests in the other direction, and beatsEntries of of gives its count. One family holds the spread of one measure.
  • Too few: