# Benchmark explorer

> Every recorded Knotkit comparison, selectable, with the raw per-repeat timings behind each bar.

Recorded timings for each comparison. A bar is the median of five within-run p50s, and the whisker spans the smallest to largest of those five. Rows in grey are the reference implementation the README names. Pick a comparison and a workload; the same numbers are in [`evidence/benchmarks/results.json`](https://github.com/jkomyno/knotkit/blob/main/evidence/benchmarks/results.json).

ComparisonWorkloadTime axislinear

The explorer needs JavaScript. The same numbers are in[results.json](https://github.com/jkomyno/knotkit/blob/main/evidence/benchmarks/results.json).

* Rows

  —

* Fastest

  —

* Baseline

  —

| Row | Median | Range |
| --- | ------ | ----- |

Measured on Node.js 26.13.1, Apple M1 Pro · Darwin 23.4.0 arm64; revision `fa46d77 + local benchmark changes`. Each point is the median of 5 repeats of within-run p50s, and the whisker spans the smallest to largest of those. Rows marked baseline are the reference implementation the README names. A ratio against a baseline is only meaningful beside what that baseline does: see [reading the baselines](/benchmarks/#reading-the-baselines).

## Reading the baselines

A ratio against a baseline means different things depending on what the baseline does. These are algorithmic-class comparisons, where Knotkit does less work by design, not the same algorithm in faster code:

* **Indexed priority queue** — the `heap-js` adapter finds each item by value with a linear search, removes it, then pushes the replacement. Knotkit updates the key in place through its index.
* **Sorted merge** — the baseline materializes and sorts the full input before taking 32 IDs. Knotkit merges lazily and stops after the prefix.
* **Integer bitset** — ordered iteration over a `Set` includes copying and sorting. For intersection, the manual `Set` loop counts directly while `Set.intersection().size` materializes the intersection first.
* **Inverted index** — the sorted-union baseline deduplicates through a `Set` and sorts.
* **Snapshot set** — each reference snapshot copies the current `Set` into a `Map`.
* **Disjoint set** — the `Map` of `Set`s baseline moves the smaller set into the larger one on merge.
* **Heap drain** — one panel also times sorting an array up front and reading it in order.

Where the same operation and policy run on both sides — deque, heap against `heap-js`, cache against `lru-cache`, graph traversal against a typed-array loop — a gap reflects layout and call overhead. Native operations can win: the direct array reads in the ordered-map and frequency-table panels are faster than the structures, and the gallery records that.

`bun run bench:overhead` measures interface overhead: each panel times Knotkit’s public call path against a hand-written loop of the same algorithm, so the ratio is the cost of the API rather than of the algorithm. It marks every panel `yes` or `no` for “same algorithm as the baseline”, including the losses. Its capture is local, so re-run it rather than reading a committed report.

## How these are measured

Each point is the median of five within-run p50s; each whisker spans the smallest to largest. The harness warms the implementations and repeats each comparison in the same process in registration order. Times cover a whole workload invocation, including construction where the panel says build, fill, or heapify. Read-only lookups use prebuilt structures.

These are local microbenchmarks. Results depend on the runtime, the machine, and the input distribution, and the panels are historical: one machine per gallery, recorded once. For caller workloads, run the suite yourself — `bun --bun run bench` — or read the per-problem numbers, which pin a seed and a fixture.
