Skip to contentSheetwrite

Performance

Recalculate 100,000 formulas, live

Change one cell that 100,000 formulas read, or move 1,000 lookups. The page times each recalculation and paint in your browser.

Rows
100,000
Formulas
101,002
Load and first calculation
…
Try it
  1. Times 100,000 revenue formulas
  2. Times 1,000 XLOOKUPs
  3. Shows the median time

What the timings include

  • Last recalculation runs from the edit call until a dependent total is readable: the engine marks the formulas that read the cell and calculates each once.
  • Frame painted adds the next frame the browser draws. Your device, browser and other tabs change every number on this page.
  • The release benchmarks measure the same work on fixed machines; see formula engine performance for their results.
Which formulas one edit recalculates, and what the page timesEditing the Price change cell recalculates the 100,000 revenue formulas that read it and their total. Moving the first SKU looked up recalculates 1,000 XLOOKUP formulas, each searching 100,000 SKUs, and their total. The page times each edit in two parts: the engine's recalculation, then the grid's paint.EditPrice change100,000 revenue formulasThat read it, and their totalEditFirst SKU looked up1,000 XLOOKUP formulasEach searching 100,000 SKUs,and their total
Which formulas one edit recalculates, and what the page timesEditing the Price change cell recalculates the 100,000 revenue formulas that read it and their total. Moving the first SKU looked up recalculates 1,000 XLOOKUP formulas, each searching 100,000 SKUs, and their total. The page times each edit in two parts: the engine's recalculation, then the grid's paint.EditPrice change100,000 revenue formulasThat read it, and their totalEditFirst SKU looked up1,000 XLOOKUP formulasEach searching 100,000 SKUs,and their total

The page times each edit in two parts: the engine's recalculation, then the grid's paint.

The code behind it

recalculation.ts
import "@sheetwrite/core/styles.css";
import { createGrid, initSheetwrite, type PackedCellBlock, type Workbook } from "@sheetwrite/core";
// A "model" sheet of 100,000 rows. Each block holds 5,000 rows of SKU, price and
// units, each with a revenue formula such as =B1*C1*(1+$G$1) that reads the
// price-change cell G1.
declare const workbook: Workbook;
declare function orderBlock(start: number, rows: number): PackedCellBlock;
// The grid fills its host, so the host needs a height
const host = document.querySelector<HTMLElement>("#grid");
if (host === null) throw new Error("Missing #grid host");
host.style.height = "480px";
// The grid mounts empty; the rows follow in blocks with a yield between them,
// so the page paints and takes input while 100,000 formulas load. Loading goes
// through applyRemoteOperations so it is not an undo step.
const grid = createGrid(host, { workbook });
for (let start = 0; start < 100_000; start += 5_000) {
await new Promise((resolve) => setTimeout(resolve, 0));
{
op: "setBlock",
range: { sheet: "model", start: { row: start, col: 0 }, end: { row: start + 4_999, col: 3 } },
block: orderBlock(start, 5_000),
},
]);
}
// One edit, timed until a dependent total is readable, then until the next frame
const started = performance.now();
patches: [{ op: "set", addr: { sheet: "model", row: 0, col: 6 }, value: { kind: "literal", value: 0.05 } }],
});
grid.store.getCell({ sheet: "model", row: 1, col: 6 }).resolved;
const recalcMs = performance.now() - started;
requestAnimationFrame(() =>
requestAnimationFrame(() => console.info({ recalcMs, paintedMs: performance.now() - started })),
);
// When the page removes the host: grid.destroy();
Show all 42 linesShow the first lines