ac-bench
Reference

Reference

@ac-bench/lib 0.6.0

The engine: runBench, the Node runtime, defineRuntimePlugin and the measurement plan.

Install
npm install @ac-bench/lib

Generated by TypeDoc from the package's exports:@ac-bench/lib.

@ac-bench/lib

Functions

Classes

Constants

Interfaces

Types

functionbaselineLocationbaselines.ts:46

baselineLocation(reference: string, fingerprintId: string, directory?: string): string

Where a baseline is filed: a path as given (resolved against the working directory), a name as <directory>/<fingerprint id>/<name>.json, so each environment keeps its own baselines under one name.

functionbenchFileLabelrun-description.ts:51

benchFileLabel(file: string, cwd?: string, paths?: Pick<typeof path.win32, "relative" | "isAbsolute" | "sep">): string

The path a run records for a bench file, and the file part of every key: relative to the working directory, /-separated, so it is the same from any checkout location.

Throws When file has no relative path from cwd (another Windows drive or share).

Parameters

paths

The path flavour, the platform’s by default.

functionclassifyEnvironmentenvironment-monitor.ts:72

classifyEnvironment(samples: readonly EnvironmentSample[]): EnvironmentVerdict

Classifies a scripted or collected series.

A monotone ramp and an oscillation of the same amplitude look identical to a variance threshold and mean completely different things, so the two tests are separated: mannKendallTrend answers “is it going somewhere” and reversalRate answers “does it keep changing its mind”.

functioncomparisonUnresolvedescalation.ts:29

comparisonUnresolved(frame: DataFrame, comparison: MeasureComparison | undefined): boolean

Whether the measurements taken so far settle the comparison.

A benchmark’s job is to order its cases. Two cases whose intervals overlap are not ordered by the numbers: whichever came out ahead did so within the noise, and another process could reverse it. That is the only signal worth spending more machine time on, and it is measure-agnostic — the parent reads it off the frame and the comparison every plugin already declares, rather than knowing what any measure’s numbers mean.

Cases without an interval are ignored: an unknown interval is not an overlapping one, and treating it as such would escalate forever.

O(n log n) in the case count, for the sort.

Returns true when some adjacent pair cannot be told apart.

Parameters

frame

The condition’s frame, from MeasurePlugin.conditionFrame.

comparison

What the measure says orders its cases. A measure with no interval bounds makes no claim tight enough to escalate on.

functioncreateMeasureDiagnosticProxymeasure-diagnostic-proxy.ts:17

createMeasureDiagnosticProxy(inner: ISink<{
  conditionTitle: string;
  kind: "condition-result";
  measure: string;
  result: unknown;
} | {
  arm: "shared" | "isolated";
  caseTitle: string;
  kind: "case-execution";
  measure: string;
  replicate: number;
  result: unknown;
} | {
  caseTitle: string;
  kind: "case-result";
  measure: string;
  result: unknown;
} | {
  file: string;
  kind: "load-error";
  message: string;
} | {
  kind: "run-description";
  machine: {
    architecture: string;
    availableParallelism: number;
    cpuGovernor: string | null;
    cpuModel: string;
    kernelRelease: string;
    logicalCores: number;
    memoryGiB: number;
    os: string;
    physicalCores: number | null;
  };
  run: {
    argv: string[];
    id: string;
    mode: string | null;
    orderSeed: number;
    plan: {
      cooldown: boolean;
      isolatedRuns: number;
      maxReplicates: number;
      replicates: number;
      retryOnInstability: number;
      rounds: number;
    };
    startedAt: string;
    tool: {
      name: "@ac-bench/lib";
      version: string;
    };
  };
} | {
  kind: "runtime-description";
  runtime: {
    capabilities: {
      allocationCounter: "v8-total-allocated" | "gc-profiler" | "heap-growth" | "browser-heap-growth" | null;
      cpuTime: boolean;
      forcedCollection: boolean;
    };
    clock: {
      readCostMs: number;
      resolutionMs: number;
      source: "performance.now";
    };
    crossOriginIsolated: boolean | null;
    device: {
      model: string;
      os: string;
      osVersion: string;
    } | null;
    engine: "v8" | "spidermonkey" | "javascriptcore";
    flags: string[];
    headless: boolean | null;
    id: string;
    isolation: "browser" | "process" | "context" | "reload";
    kind: "node" | "browser";
    product: string;
    userAgent: string | null;
    version: string;
  };
} | {
  gate: {
    conditionPath: number[];
    declaration: {
      denominators: string[];
      id?: string;
      kind: "ratio";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      numerator: string;
      rationale?: string;
      runtimes?: string[];
    } | {
      id?: string;
      kind: "difference";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      reference: string;
      runtimes?: string[];
      subject: string;
    } | {
      id?: string;
      kind: "bound";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      runtimes?: string[];
      subject: string;
    };
    file: string;
    origin: "suite";
  } | {
    declaration: {
      denominators: (string | {
        case: string;
        condition: ... | ...;
        file?: ... | ...;
      } | {
        case: string;
      })[];
      id?: string;
      kind: "ratio";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      numerator: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      rationale?: string;
      runtimes?: string[];
    } | {
      id?: string;
      kind: "difference";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      reference: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      runtimes?: string[];
      subject: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
    } | {
      id?: string;
      kind: "bound";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      runtimes?: string[];
      subject: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
    } | {
      id?: string;
      kind: "baseline";
      maxDispersion?: number;
      maxRegression?: number;
      metric?: string;
      normalizeBy?: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      rationale?: string;
      runtimes?: string[];
      subjects?: (string | {
        case: ...;
        condition: ...;
        file?: ...;
      } | {
        case: ...;
      })[];
    };
    origin: "config" | "cli";
  };
  kind: "gate-declaration";
} | {
  kind: "gate-verdict";
  verdict: {
    adjustedPValue: number | null;
    degreesOfFreedom: number | null;
    dispersion: number | null;
    escalatedReplicates: number;
    estimate: number | null;
    estimator: "paired" | "unpaired" | "single" | null;
    executions: number[];
    id: string;
    interval: {
      level: number;
      lower: number;
      upper: number;
    } | null;
    kind: "ratio" | "difference" | "bound" | "baseline";
    message: string;
    metric: {
      direction: "lower-is-better" | "higher-is-better";
      name: string;
      scale: "log" | "linear";
      unit: {
        scale: number;
        symbol: string;
      };
    };
    origin: "suite" | "config" | "cli";
    pValue: number | null;
    rationale?: string;
    reason: "decided" | "interval-contains-threshold" | "multiplicity" | "dispersion-exceeds-limit" | "too-few-executions" | "no-threshold" | "case-failed" | "case-filtered" | "metric-unavailable" | "non-positive-value" | "runtime-unsupported" | "runtime-unavailable" | "baseline-case-missing" | "baseline-environment-mismatch";
    runtime: string;
    subjects: {
      caseTitle: string;
      conditionTitles: string[];
      file: string;
      runtime: string;
    }[];
    threshold: {
      max?: number;
      min?: number;
    };
    verdict: "error" | "pass" | "fail" | "inconclusive" | "reported" | "skipped" | "not-applicable" | "incomparable";
  };
} | {
  completedUnits: number;
  kind: "run-progress";
  totalUnits: number;
} | {
  cases: {
    selected: boolean;
    title: string;
  }[];
  conditionPath: number[];
  file: string;
  kind: "unit-declaration";
  measure: string;
  runtime: string;
  titles: string[];
}>, registry: MeasureRegistry): ISink<{
  conditionTitle: string;
  kind: "condition-result";
  measure: string;
  result: unknown;
} | {
  arm: "shared" | "isolated";
  caseTitle: string;
  kind: "case-execution";
  measure: string;
  replicate: number;
  result: unknown;
} | {
  caseTitle: string;
  kind: "case-result";
  measure: string;
  result: unknown;
} | {
  file: string;
  kind: "load-error";
  message: string;
} | {
  kind: "run-description";
  machine: {
    architecture: string;
    availableParallelism: number;
    cpuGovernor: string | null;
    cpuModel: string;
    kernelRelease: string;
    logicalCores: number;
    memoryGiB: number;
    os: string;
    physicalCores: number | null;
  };
  run: {
    argv: string[];
    id: string;
    mode: string | null;
    orderSeed: number;
    plan: {
      cooldown: boolean;
      isolatedRuns: number;
      maxReplicates: number;
      replicates: number;
      retryOnInstability: number;
      rounds: number;
    };
    startedAt: string;
    tool: {
      name: "@ac-bench/lib";
      version: string;
    };
  };
} | {
  kind: "runtime-description";
  runtime: {
    capabilities: {
      allocationCounter: "v8-total-allocated" | "gc-profiler" | "heap-growth" | "browser-heap-growth" | null;
      cpuTime: boolean;
      forcedCollection: boolean;
    };
    clock: {
      readCostMs: number;
      resolutionMs: number;
      source: "performance.now";
    };
    crossOriginIsolated: boolean | null;
    device: {
      model: string;
      os: string;
      osVersion: string;
    } | null;
    engine: "v8" | "spidermonkey" | "javascriptcore";
    flags: string[];
    headless: boolean | null;
    id: string;
    isolation: "browser" | "process" | "context" | "reload";
    kind: "node" | "browser";
    product: string;
    userAgent: string | null;
    version: string;
  };
} | {
  gate: {
    conditionPath: number[];
    declaration: {
      denominators: string[];
      id?: string;
      kind: "ratio";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      numerator: string;
      rationale?: string;
      runtimes?: string[];
    } | {
      id?: string;
      kind: "difference";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      reference: string;
      runtimes?: string[];
      subject: string;
    } | {
      id?: string;
      kind: "bound";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      runtimes?: string[];
      subject: string;
    };
    file: string;
    origin: "suite";
  } | {
    declaration: {
      denominators: (string | {
        case: string;
        condition: ... | ...;
        file?: ... | ...;
      } | {
        case: string;
      })[];
      id?: string;
      kind: "ratio";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      numerator: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      rationale?: string;
      runtimes?: string[];
    } | {
      id?: string;
      kind: "difference";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      reference: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      runtimes?: string[];
      subject: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
    } | {
      id?: string;
      kind: "bound";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      runtimes?: string[];
      subject: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
    } | {
      id?: string;
      kind: "baseline";
      maxDispersion?: number;
      maxRegression?: number;
      metric?: string;
      normalizeBy?: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      rationale?: string;
      runtimes?: string[];
      subjects?: (string | {
        case: ...;
        condition: ...;
        file?: ...;
      } | {
        case: ...;
      })[];
    };
    origin: "config" | "cli";
  };
  kind: "gate-declaration";
} | {
  kind: "gate-verdict";
  verdict: {
    adjustedPValue: number | null;
    degreesOfFreedom: number | null;
    dispersion: number | null;
    escalatedReplicates: number;
    estimate: number | null;
    estimator: "paired" | "unpaired" | "single" | null;
    executions: number[];
    id: string;
    interval: {
      level: number;
      lower: number;
      upper: number;
    } | null;
    kind: "ratio" | "difference" | "bound" | "baseline";
    message: string;
    metric: {
      direction: "lower-is-better" | "higher-is-better";
      name: string;
      scale: "log" | "linear";
      unit: {
        scale: number;
        symbol: string;
      };
    };
    origin: "suite" | "config" | "cli";
    pValue: number | null;
    rationale?: string;
    reason: "decided" | "interval-contains-threshold" | "multiplicity" | "dispersion-exceeds-limit" | "too-few-executions" | "no-threshold" | "case-failed" | "case-filtered" | "metric-unavailable" | "non-positive-value" | "runtime-unsupported" | "runtime-unavailable" | "baseline-case-missing" | "baseline-environment-mismatch";
    runtime: string;
    subjects: {
      caseTitle: string;
      conditionTitles: string[];
      file: string;
      runtime: string;
    }[];
    threshold: {
      max?: number;
      min?: number;
    };
    verdict: "error" | "pass" | "fail" | "inconclusive" | "reported" | "skipped" | "not-applicable" | "incomparable";
  };
} | {
  completedUnits: number;
  kind: "run-progress";
  totalUnits: number;
} | {
  cases: {
    selected: boolean;
    title: string;
  }[];
  conditionPath: number[];
  file: string;
  kind: "unit-declaration";
  measure: string;
  runtime: string;
  titles: string[];
}>

Derives the generic diagnostic events from a measure’s typed warnings, in the parent.

Warnings live in the typed result, where the plugin renders them inline per row; generic sinks need them as severity-carrying events. Emitting both from the child would give one fact two sources of truth, so the translation happens here instead — right after the data event that carries the result and before the case’s scope-end.

functioncurrentEnvironmentcurrent-environment.ts:2

currentEnvironment(): {
  arch: string;
  platform: string;
  runtime: string;
  timestamp: string;
}

Environment captured at run time, carried into live tables and exports.

functiondescribeMachinerun-description.ts:69

describeMachine(sysfsRoot?: string): Promise<{
  architecture: string;
  availableParallelism: number;
  cpuGovernor: string | null;
  cpuModel: string;
  kernelRelease: string;
  logicalCores: number;
  memoryGiB: number;
  os: string;
  physicalCores: number | null;
}>

What a reader needs to tell two machines apart: CPU, memory, OS, governor. No host name, no user name.

functiondescribeRuntimerun-description.ts:108

describeRuntime(launch: ReturnType<ExecutionRuntime["describe"]>, environment: {
  capabilities: {
    allocationCounter: "v8-total-allocated" | "gc-profiler" | "heap-growth" | "browser-heap-growth" | null;
    cpuTime: boolean;
    forcedCollection: boolean;
  };
  clock: {
    readCostMs: number;
    resolutionMs: number;
    source: "performance.now";
  };
  crossOriginIsolated: boolean | null;
  engineVersion: string;
  userAgent: string | null;
}, measured?: {
  readonly flags?: readonly string[];
  readonly forcedCollection?: boolean;
}): {
  capabilities: {
    allocationCounter: "v8-total-allocated" | "gc-profiler" | "heap-growth" | "browser-heap-growth" | null;
    cpuTime: boolean;
    forcedCollection: boolean;
  };
  clock: {
    readCostMs: number;
    resolutionMs: number;
    source: "performance.now";
  };
  crossOriginIsolated: boolean | null;
  device: {
    model: string;
    os: string;
    osVersion: string;
  } | null;
  engine: "v8" | "spidermonkey" | "javascriptcore";
  flags: string[];
  headless: boolean | null;
  id: string;
  isolation: "browser" | "process" | "context" | "reload";
  kind: "node" | "browser";
  product: string;
  userAgent: string | null;
  version: string;
}

A runtime’s full description: what its launcher knows, completed by what a child measured of itself in its hello.

Parameters

launch

The runtime’s describe().

environment

A child’s hello environment.

measured

What the run’s measuring children add: the switches their measures asked for, after the runtime’s own (both as given, in order and with their repetitions, since --import and the like act once each), and whether any of them could force a collection.

functionisBaselinePathbaselines.ts:33

isBaselinePath(reference: string): boolean

Whether reference is a path rather than a name: it holds a / (or the platform’s separator) or ends with .json.

functionloadBaselinebaselines.ts:64

loadBaseline(reference: string, current: Pick<BenchArchive, "machine" | "runtimes" | "run">, directory?: string): Promise<BenchArchive>

Reads a baseline: a path as given, a name in the directory of current’s fingerprint.

Throws When the file is missing or not a bench archive; for a name filed only under other environments, the message lists their files (compare with one through its path and allowForeignBaseline).

functionrunBenchrun-bench.ts:252

runBench(files: readonly string[], measures: readonly MeasurePlugin[], reporters: readonly ReporterPlugin[], options?: BenchRunOptions): Promise<BenchRunOutcome>

Discovers every bench file’s condition tree in every runtime first, then measures each fork unit in a child of its own, runtime after runtime, closing every sink once the last one finishes.

With more than one runtime, or a single one other than Node, every runtime gets a scope of its own (titled by product and version, keyed and attributed by its id) and every key carries the runtime’s id; a Node-only run keeps the scope tree and the keys it always had.

When signal aborts, the in-flight child is terminated, every condition not yet started is skipped, and the sinks are still closed.

A file that fails to load is reported to stderr as a load-error and skipped — the run continues with the next file rather than crashing over one broken bench file. A runtime that cannot be created or prepared is reported as a runtime-failed error and skipped the same way.

Throws Before anything runs, when a file has no path relative to the working directory (another Windows drive or share), since its results could not be keyed the same on another machine.

Throws Before anything runs, when runtimes is empty or names one id twice.

Parameters

files

Bench files to run, already discovered.

measures

Registered for the measures files declare conditions for.

reporters

Every reporter the run reports to; each sink is closed when it ends.

functionrunDiscoveredFileisolated-runner.ts:259

runDiscoveredFile(file: string, conditions: readonly DiscoveredCondition[], sink: ISink<{
  conditionTitle: string;
  kind: "condition-result";
  measure: string;
  result: unknown;
} | {
  arm: "shared" | "isolated";
  caseTitle: string;
  kind: "case-execution";
  measure: string;
  replicate: number;
  result: unknown;
} | {
  caseTitle: string;
  kind: "case-result";
  measure: string;
  result: unknown;
} | {
  file: string;
  kind: "load-error";
  message: string;
} | {
  kind: "run-description";
  machine: {
    architecture: string;
    availableParallelism: number;
    cpuGovernor: string | null;
    cpuModel: string;
    kernelRelease: string;
    logicalCores: number;
    memoryGiB: number;
    os: string;
    physicalCores: number | null;
  };
  run: {
    argv: string[];
    id: string;
    mode: string | null;
    orderSeed: number;
    plan: {
      cooldown: boolean;
      isolatedRuns: number;
      maxReplicates: number;
      replicates: number;
      retryOnInstability: number;
      rounds: number;
    };
    startedAt: string;
    tool: {
      name: "@ac-bench/lib";
      version: string;
    };
  };
} | {
  kind: "runtime-description";
  runtime: {
    capabilities: {
      allocationCounter: "v8-total-allocated" | "gc-profiler" | "heap-growth" | "browser-heap-growth" | null;
      cpuTime: boolean;
      forcedCollection: boolean;
    };
    clock: {
      readCostMs: number;
      resolutionMs: number;
      source: "performance.now";
    };
    crossOriginIsolated: boolean | null;
    device: {
      model: string;
      os: string;
      osVersion: string;
    } | null;
    engine: "v8" | "spidermonkey" | "javascriptcore";
    flags: string[];
    headless: boolean | null;
    id: string;
    isolation: "browser" | "process" | "context" | "reload";
    kind: "node" | "browser";
    product: string;
    userAgent: string | null;
    version: string;
  };
} | {
  gate: {
    conditionPath: number[];
    declaration: {
      denominators: string[];
      id?: string;
      kind: "ratio";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      numerator: string;
      rationale?: string;
      runtimes?: string[];
    } | {
      id?: string;
      kind: "difference";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      reference: string;
      runtimes?: string[];
      subject: string;
    } | {
      id?: string;
      kind: "bound";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      runtimes?: string[];
      subject: string;
    };
    file: string;
    origin: "suite";
  } | {
    declaration: {
      denominators: (string | {
        case: string;
        condition: ... | ...;
        file?: ... | ...;
      } | {
        case: string;
      })[];
      id?: string;
      kind: "ratio";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      numerator: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      rationale?: string;
      runtimes?: string[];
    } | {
      id?: string;
      kind: "difference";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      reference: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      runtimes?: string[];
      subject: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
    } | {
      id?: string;
      kind: "bound";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      runtimes?: string[];
      subject: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
    } | {
      id?: string;
      kind: "baseline";
      maxDispersion?: number;
      maxRegression?: number;
      metric?: string;
      normalizeBy?: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      rationale?: string;
      runtimes?: string[];
      subjects?: (string | {
        case: ...;
        condition: ...;
        file?: ...;
      } | {
        case: ...;
      })[];
    };
    origin: "config" | "cli";
  };
  kind: "gate-declaration";
} | {
  kind: "gate-verdict";
  verdict: {
    adjustedPValue: number | null;
    degreesOfFreedom: number | null;
    dispersion: number | null;
    escalatedReplicates: number;
    estimate: number | null;
    estimator: "paired" | "unpaired" | "single" | null;
    executions: number[];
    id: string;
    interval: {
      level: number;
      lower: number;
      upper: number;
    } | null;
    kind: "ratio" | "difference" | "bound" | "baseline";
    message: string;
    metric: {
      direction: "lower-is-better" | "higher-is-better";
      name: string;
      scale: "log" | "linear";
      unit: {
        scale: number;
        symbol: string;
      };
    };
    origin: "suite" | "config" | "cli";
    pValue: number | null;
    rationale?: string;
    reason: "decided" | "interval-contains-threshold" | "multiplicity" | "dispersion-exceeds-limit" | "too-few-executions" | "no-threshold" | "case-failed" | "case-filtered" | "metric-unavailable" | "non-positive-value" | "runtime-unsupported" | "runtime-unavailable" | "baseline-case-missing" | "baseline-environment-mismatch";
    runtime: string;
    subjects: {
      caseTitle: string;
      conditionTitles: string[];
      file: string;
      runtime: string;
    }[];
    threshold: {
      max?: number;
      min?: number;
    };
    verdict: "error" | "pass" | "fail" | "inconclusive" | "reported" | "skipped" | "not-applicable" | "incomparable";
  };
} | {
  completedUnits: number;
  kind: "run-progress";
  totalUnits: number;
} | {
  cases: {
    selected: boolean;
    title: string;
  }[];
  conditionPath: number[];
  file: string;
  kind: "unit-declaration";
  measure: string;
  runtime: string;
  titles: string[];
}>, registry: MeasureRegistry, options?: IsolatedRunOptions): Promise<void>

Runs every executable leaf of an already discovered file in a child of its own, as runFileIsolated does once discovery is over.

A leaf whose measure does not run in options.runtimeDescription (supportsRuntime) forks nothing: its scope is skipped with the reason, a runtime-unsupported warning, and every selected case archived "unsupported".

Parameters

conditions

What a discovery child returned for file.

functionrunFileIsolatedisolated-runner.ts:203

runFileIsolated(file: string, sink: ISink<{
  conditionTitle: string;
  kind: "condition-result";
  measure: string;
  result: unknown;
} | {
  arm: "shared" | "isolated";
  caseTitle: string;
  kind: "case-execution";
  measure: string;
  replicate: number;
  result: unknown;
} | {
  caseTitle: string;
  kind: "case-result";
  measure: string;
  result: unknown;
} | {
  file: string;
  kind: "load-error";
  message: string;
} | {
  kind: "run-description";
  machine: {
    architecture: string;
    availableParallelism: number;
    cpuGovernor: string | null;
    cpuModel: string;
    kernelRelease: string;
    logicalCores: number;
    memoryGiB: number;
    os: string;
    physicalCores: number | null;
  };
  run: {
    argv: string[];
    id: string;
    mode: string | null;
    orderSeed: number;
    plan: {
      cooldown: boolean;
      isolatedRuns: number;
      maxReplicates: number;
      replicates: number;
      retryOnInstability: number;
      rounds: number;
    };
    startedAt: string;
    tool: {
      name: "@ac-bench/lib";
      version: string;
    };
  };
} | {
  kind: "runtime-description";
  runtime: {
    capabilities: {
      allocationCounter: "v8-total-allocated" | "gc-profiler" | "heap-growth" | "browser-heap-growth" | null;
      cpuTime: boolean;
      forcedCollection: boolean;
    };
    clock: {
      readCostMs: number;
      resolutionMs: number;
      source: "performance.now";
    };
    crossOriginIsolated: boolean | null;
    device: {
      model: string;
      os: string;
      osVersion: string;
    } | null;
    engine: "v8" | "spidermonkey" | "javascriptcore";
    flags: string[];
    headless: boolean | null;
    id: string;
    isolation: "browser" | "process" | "context" | "reload";
    kind: "node" | "browser";
    product: string;
    userAgent: string | null;
    version: string;
  };
} | {
  gate: {
    conditionPath: number[];
    declaration: {
      denominators: string[];
      id?: string;
      kind: "ratio";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      numerator: string;
      rationale?: string;
      runtimes?: string[];
    } | {
      id?: string;
      kind: "difference";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      reference: string;
      runtimes?: string[];
      subject: string;
    } | {
      id?: string;
      kind: "bound";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      runtimes?: string[];
      subject: string;
    };
    file: string;
    origin: "suite";
  } | {
    declaration: {
      denominators: (string | {
        case: string;
        condition: ... | ...;
        file?: ... | ...;
      } | {
        case: string;
      })[];
      id?: string;
      kind: "ratio";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      numerator: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      rationale?: string;
      runtimes?: string[];
    } | {
      id?: string;
      kind: "difference";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      reference: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      runtimes?: string[];
      subject: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
    } | {
      id?: string;
      kind: "bound";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      runtimes?: string[];
      subject: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
    } | {
      id?: string;
      kind: "baseline";
      maxDispersion?: number;
      maxRegression?: number;
      metric?: string;
      normalizeBy?: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      rationale?: string;
      runtimes?: string[];
      subjects?: (string | {
        case: ...;
        condition: ...;
        file?: ...;
      } | {
        case: ...;
      })[];
    };
    origin: "config" | "cli";
  };
  kind: "gate-declaration";
} | {
  kind: "gate-verdict";
  verdict: {
    adjustedPValue: number | null;
    degreesOfFreedom: number | null;
    dispersion: number | null;
    escalatedReplicates: number;
    estimate: number | null;
    estimator: "paired" | "unpaired" | "single" | null;
    executions: number[];
    id: string;
    interval: {
      level: number;
      lower: number;
      upper: number;
    } | null;
    kind: "ratio" | "difference" | "bound" | "baseline";
    message: string;
    metric: {
      direction: "lower-is-better" | "higher-is-better";
      name: string;
      scale: "log" | "linear";
      unit: {
        scale: number;
        symbol: string;
      };
    };
    origin: "suite" | "config" | "cli";
    pValue: number | null;
    rationale?: string;
    reason: "decided" | "interval-contains-threshold" | "multiplicity" | "dispersion-exceeds-limit" | "too-few-executions" | "no-threshold" | "case-failed" | "case-filtered" | "metric-unavailable" | "non-positive-value" | "runtime-unsupported" | "runtime-unavailable" | "baseline-case-missing" | "baseline-environment-mismatch";
    runtime: string;
    subjects: {
      caseTitle: string;
      conditionTitles: string[];
      file: string;
      runtime: string;
    }[];
    threshold: {
      max?: number;
      min?: number;
    };
    verdict: "error" | "pass" | "fail" | "inconclusive" | "reported" | "skipped" | "not-applicable" | "incomparable";
  };
} | {
  completedUnits: number;
  kind: "run-progress";
  totalUnits: number;
} | {
  cases: {
    selected: boolean;
    title: string;
  }[];
  conditionPath: number[];
  file: string;
  kind: "unit-declaration";
  measure: string;
  runtime: string;
  titles: string[];
}>, registry: MeasureRegistry, options?: IsolatedRunOptions): Promise<void>

Discovers file’s condition tree in its own child, then runs every executable leaf in a child of its own.

Enclosing scopes are opened here rather than in a child: one such scope spans several children, so only the parent can own it.

Parameters

sink

Receives every event of every child, in order.

registry

Resolves each leaf’s measure, whose scheduling constrains the fork.

functionrunForkUnitInChildfork-runner.ts:157

runForkUnitInChild(start: Omit<StartMessage, "t" | "runtime">, sink: ISink<{
  conditionTitle: string;
  kind: "condition-result";
  measure: string;
  result: unknown;
} | {
  arm: "shared" | "isolated";
  caseTitle: string;
  kind: "case-execution";
  measure: string;
  replicate: number;
  result: unknown;
} | {
  caseTitle: string;
  kind: "case-result";
  measure: string;
  result: unknown;
} | {
  file: string;
  kind: "load-error";
  message: string;
} | {
  kind: "run-description";
  machine: {
    architecture: string;
    availableParallelism: number;
    cpuGovernor: string | null;
    cpuModel: string;
    kernelRelease: string;
    logicalCores: number;
    memoryGiB: number;
    os: string;
    physicalCores: number | null;
  };
  run: {
    argv: string[];
    id: string;
    mode: string | null;
    orderSeed: number;
    plan: {
      cooldown: boolean;
      isolatedRuns: number;
      maxReplicates: number;
      replicates: number;
      retryOnInstability: number;
      rounds: number;
    };
    startedAt: string;
    tool: {
      name: "@ac-bench/lib";
      version: string;
    };
  };
} | {
  kind: "runtime-description";
  runtime: {
    capabilities: {
      allocationCounter: "v8-total-allocated" | "gc-profiler" | "heap-growth" | "browser-heap-growth" | null;
      cpuTime: boolean;
      forcedCollection: boolean;
    };
    clock: {
      readCostMs: number;
      resolutionMs: number;
      source: "performance.now";
    };
    crossOriginIsolated: boolean | null;
    device: {
      model: string;
      os: string;
      osVersion: string;
    } | null;
    engine: "v8" | "spidermonkey" | "javascriptcore";
    flags: string[];
    headless: boolean | null;
    id: string;
    isolation: "browser" | "process" | "context" | "reload";
    kind: "node" | "browser";
    product: string;
    userAgent: string | null;
    version: string;
  };
} | {
  gate: {
    conditionPath: number[];
    declaration: {
      denominators: string[];
      id?: string;
      kind: "ratio";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      numerator: string;
      rationale?: string;
      runtimes?: string[];
    } | {
      id?: string;
      kind: "difference";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      reference: string;
      runtimes?: string[];
      subject: string;
    } | {
      id?: string;
      kind: "bound";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      runtimes?: string[];
      subject: string;
    };
    file: string;
    origin: "suite";
  } | {
    declaration: {
      denominators: (string | {
        case: string;
        condition: ... | ...;
        file?: ... | ...;
      } | {
        case: string;
      })[];
      id?: string;
      kind: "ratio";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      numerator: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      rationale?: string;
      runtimes?: string[];
    } | {
      id?: string;
      kind: "difference";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      reference: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      runtimes?: string[];
      subject: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
    } | {
      id?: string;
      kind: "bound";
      max?: number;
      maxDispersion?: number;
      metric?: string;
      min?: number;
      rationale?: string;
      runtimes?: string[];
      subject: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
    } | {
      id?: string;
      kind: "baseline";
      maxDispersion?: number;
      maxRegression?: number;
      metric?: string;
      normalizeBy?: string | {
        case: string;
        condition: string | ...[];
        file?: string;
      } | {
        case: string;
      };
      rationale?: string;
      runtimes?: string[];
      subjects?: (string | {
        case: ...;
        condition: ...;
        file?: ...;
      } | {
        case: ...;
      })[];
    };
    origin: "config" | "cli";
  };
  kind: "gate-declaration";
} | {
  kind: "gate-verdict";
  verdict: {
    adjustedPValue: number | null;
    degreesOfFreedom: number | null;
    dispersion: number | null;
    escalatedReplicates: number;
    estimate: number | null;
    estimator: "paired" | "unpaired" | "single" | null;
    executions: number[];
    id: string;
    interval: {
      level: number;
      lower: number;
      upper: number;
    } | null;
    kind: "ratio" | "difference" | "bound" | "baseline";
    message: string;
    metric: {
      direction: "lower-is-better" | "higher-is-better";
      name: string;
      scale: "log" | "linear";
      unit: {
        scale: number;
        symbol: string;
      };
    };
    origin: "suite" | "config" | "cli";
    pValue: number | null;
    rationale?: string;
    reason: "decided" | "interval-contains-threshold" | "multiplicity" | "dispersion-exceeds-limit" | "too-few-executions" | "no-threshold" | "case-failed" | "case-filtered" | "metric-unavailable" | "non-positive-value" | "runtime-unsupported" | "runtime-unavailable" | "baseline-case-missing" | "baseline-environment-mismatch";
    runtime: string;
    subjects: {
      caseTitle: string;
      conditionTitles: string[];
      file: string;
      runtime: string;
    }[];
    threshold: {
      max?: number;
      min?: number;
    };
    verdict: "error" | "pass" | "fail" | "inconclusive" | "reported" | "skipped" | "not-applicable" | "incomparable";
  };
} | {
  completedUnits: number;
  kind: "run-progress";
  totalUnits: number;
} | {
  cases: {
    selected: boolean;
    title: string;
  }[];
  conditionPath: number[];
  file: string;
  kind: "unit-declaration";
  measure: string;
  runtime: string;
  titles: string[];
}>, onDiagnostic: (diagnostic: {
  attributes?: Record<string, unknown>;
  code?: string;
  message: string;
  severity: "info" | "warning" | "error";
  source?: SourceLocation;
}) => void, options?: ForkOptions): Promise<ChildOutcome>

Starts a child, runs one fork unit in it, and replays everything it reports into sink in order.

The child’s own scopes are closed out here if it dies without saying it was done, so a crash can never strand a scope.

Parameters

start

The start message; its runtime is the one the child runs in.

functionsaveBaselinebaselines.ts:121

saveBaseline(archive: BenchArchive, reference: string, directory?: string): Promise<string>

Files archive as a baseline: under reference as a path, or as a name in the directory of its own fingerprint.

Returns Where it was written.

functionverdictDiagnosticmeasure-diagnostic-proxy.ts:72

verdictDiagnostic(verdict: GateVerdict): {
  attributes?: Record<string, unknown>;
  code?: string;
  message: string;
  severity: "info" | "warning" | "error";
  source?: SourceLocation;
}

A gate verdict as the generic diagnostic sinks read it: error for a fail or an error, warning for an undecided or incomparable gate, info otherwise. Its code is gate-<verdict>, so a sink that renders gates itself can leave these out.

classCooldownGatecooldown.ts:86

class CooldownGate

Waits between fork units until the machine stops recovering, never inside a timed case.

Waiting is preventive where retrying is corrective: it avoids paying for a bad measurement rather than noticing one afterwards. The stopping rule is the derivative, not the baseline — ambient conditions may simply have changed, so waiting for the exact starting temperature would never terminate.

new (probe: EnvironmentProbe, baseline: EnvironmentBaseline, options?: CooldownOptions): CooldownGate
get totalCooldownMs(): number

Time already spent cooling across every gate so far.

settle(signal?: AbortSignal): Promise<CooldownResult>

classIpcReportReceiveripc-report-receiver.ts:53

class IpcReportReceiver

Turns one child’s message stream into sink writes, asserting the sequence, renewing the child’s credit, and remembering which scopes it left open so a crash can still be closed out.

new (input: IpcReportReceiverInput): IpcReportReceiver
fatal: unknown

The error the child reported as fatal, if any.

status: "skipped" | "ok" | "failed" | "cancelled" | null

The status the child reported, or null while it is still running.

get deepestOpenScope(): string | null

The innermost scope the child has open, for attributing its output.

get openScopes(): readonly string[]

Scopes the child opened and never closed, deepest last.

closeOpenScopes(error: unknown): Promise<void>

Writes a synthetic scope-end for everything the child left open, so a crash cannot strand a scope. Innermost first.

receive(raw: unknown): Promise<void>

constNODE_RUNTIME_IDrun-description.ts:102

const NODE_RUNTIME_ID: "node"

The id of the runtime every run measures in unless another is selected. Its conditions keep keys without a runtime prefix, so a Node-only run keys its scopes as it always has.

interfaceBenchChildruntime.ts:25

interface BenchChild extends AsyncDisposable

One measuring (or discovering) context: a Node process, a browser page.

readonly label: string

For logs: "pid 4242", "chromium page 3".

readonly pid: number | undefined

The OS process the monitor should watch, when there is one on this host.

onMessage(listener: Callable<[message: unknown]>): CallableNoArgs

Every message the child sends, in order, from the moment it is called.

Returns Unsubscribes.

onOutput(listener: Callable<[stream: "stdout" | "stderr", line: string]>): CallableNoArgs

Returns Unsubscribes.

send(message: { arm: "shared" | "isolated"; caseFilter?: string[]; conditionPath: number[]; conditionTitles: string[]; emitSamples: boolean; file: string; fileLabel: string; hashSeed?: number; measureOptions?: Record<string, unknown>; orderSeed: number; parentScopeId: string | null; profile?: boolean; replicate: number; rounds: number; runtime: { id: string; kind: "node" | "browser"; }; t: "start"; } | { artifactCacheRoot: string; runId: string; setupFiles?: string[]; t: "hello"; version: number; } | { file: string; t: "list"; } | { seq: number; t: "ack"; } | { reason: string; t: "abort"; }): Promise<void>

Resolves once the child side accepted the message.

terminate(): Promise<void>

Ask, then force: SIGTERM then SIGKILL, or close the page then the browser.

waitForExit(): Promise<ChildExit>

Resolves once the child is gone, however it went. Never rejects.

interfaceExecutionRuntimeruntime.ts:64

interface ExecutionRuntime extends AsyncDisposable

Where bench files run: everything a run needs to start a child, exchange protocol messages with it and notice it died. Discovery, the measurement plan, pooling and reporting are the same whatever the runtime.

readonly environmentProbe?: EnvironmentProbe

Host- or device-side probe for the environment monitor and cooldown. Absent: the host’s own.

readonly id: string
readonly kind: "node" | "browser"
describe(): Omit<RuntimeDescription, "clock" | "crossOriginIsolated" | "userAgent" | "capabilities">

The launch-side half of the description; a child’s hello completes it.

prepare(files: readonly string[], signal: AbortSignal): Promise<void>

Called once per run with every selected file: bundling, servers, devices.

spawn(request: ChildSpawnRequest): Promise<BenchChild>

typeBenchRunOptionsrun-bench.ts:92

type BenchRunOptions = unknown

How a run is carried out, already resolved.

Nothing here is an intent: naming one (--mode rigorous, a reporter id, a glob) and turning it into these values is configuration, and belongs to whoever parses it.