A Playwright benchmark that compares AG Grid (Community) and Infinite Table on
the same data, in the same browser, with the same interactions - at 1M rows
(BENCH_SIZES=300k,1m adds 300k).
cd examples
npm run benchmark # production build + all scenarios, 1M rows
npm run benchmark:run # reuse the last buildThe report goes to examples/benchmark-results/<run id>/report.md (also
copied to benchmark-results/latest.md); the raw samples are in
results.json next to it. benchmark-results/ is git-ignored.
Here the benchmark runs against the grid's source. The same files are in datagrid-performance-comparison, where the grids are installed from npm, any versions can be compared, and CI publishes the results for every new version. Keep the files of this folder identical in the two repositories (all but this README).
That repository also measures MUI X Data Grid and TanStack Table. Their pages
(MuiBenchmark.tsx, TanStackBenchmark.tsx) and their dependencies are only
there: this app measures AG Grid and Infinite Table, which is what
playwright.benchmark.config.ts sets BENCH_GRIDS to. The spec and the
report handle any of the four grids.
| File | |
|---|---|
src/pages/benchmark/<grid>-<size>.page.tsx |
the demo pages (ag-grid-300k, infinite-1m, ...) - also in the regular examples app, e.g. http://localhost:5555/benchmark/infinite-1m |
src/pages/benchmark/*.bench.tsx |
the same pages, as entries of the production benchmark build |
data.ts |
the deterministic dataset (20 columns) - both grids import it, the spec checks the checksum |
updates.ts |
the views (sorted, filtered, grouped) and the row changes of the live-update scenarios (updates-*) |
AgGridBenchmark.tsx, InfiniteBenchmark.tsx |
each grid with its defaults (only row/header height and column widths are set) + its DOM adapter |
BenchmarkPage.tsx, harness.ts |
identical page shell; window.__bench - what the spec calls in the page (mount, jumps, probes, ...) |
grid-comparison.bench.ts |
the Playwright spec: scenarios, runs, report |
benchUtils.ts |
trace parsing, statistics, report |
../../playwright.benchmark.config.ts |
separate config: 1 worker, no retries, long timeouts, next start on port 5560 |
../../scripts/grid-benchmark-build.js |
GRID_BENCHMARK=1 next build into .next-benchmark (only the *.bench.tsx pages, __DEV__ off), so it can run while next dev is running |
- Production builds only. The spec refuses dev builds (
BENCH_ALLOW_DEV=1to try it againstnext devanyway). - Fresh browser context per run, A/B interleaved: every scenario runs
BENCH_WARMUP+BENCH_RUNStimes per grid, alternating which grid goes first; warmup runs are discarded. - Latency from traces, as in
js-framework-benchmark:
from the input (pointerdown,
setState, settingscrollTop) to the end of the firstCommitafter the DOM shows the expected content.- visible - the first and last visible rows/columns show the right content, at the right place
- settled - the first frame committed after the grid's last DOM mutation (aria-live regions ignored). We don't use js-framework-benchmark's "last rAF/timer" rule, because grids schedule debounce timers that do no visible work.
- Scrolling uses real input:
Input.synthesizeScrollGesture(Chrome's input pipeline, threaded scrolling), the same gesture for both grids.- frame outcomes from the compositor's
PipelineReportertrace events: presented with the main-thread update, presented without it ("partial" - the compositor scrolled what it had), or dropped - rAF intervals and Long Animation Frames from the page
- frame outcomes from the compositor's
- Correctness probe (
correctness-*): after every frame, samples points across the body and checks that the cell there is the one that should be there for the current scroll position - "blank" (no cell) or "wrong" (another row's content, or a cell lagging the scroll). It reads layout, so it runs in its own pass, never together with timing. - Live updates (
updates-low-*,updates-high-*): the grid mounts with the rows as they are, sorted, filtered or grouped (?view=on the page), and gets changed rows - random ones plus the ones in the viewport - through the API it documents for that (dataSourceApi.updateDataArrayin Infinite Table,applyTransactionin AG Grid). Low frequency: one update at a time, measured to the frame that shows it. High frequency: a feed of 50 updates a second, handed to the grid once per animation frame; lag at the end, frame rate and main-thread work (frames and blocking time from the trace, not rAF: a main thread blocked for seconds gets few callbacks). The grouped scenarios only run for grids with row grouping and aggregation (Infinite Table and TanStack Table), so they are skipped here, where Infinite Table is the only one of the two. - Screencast (
visual-blank-vertical): records what the compositor actually displays during a fast scroll and counts blank rows - this also catches the compositor scrolling ahead of the main thread. - Scroll range (setup): browsers cap element sizes (16.7M-33.5M px in Chrome, depending on the version), and 1M rows x 40px is more than that. The setup scrolls each grid to the middle and to the end, to report whether the last row is reachable and how the scrollbar maps onto the rows. The probes and jumps use that mapping, so they measure rendering - not mapping differences.
- Same body height (setup): the setup measures the scrolling body of both
grids and makes the box of the shorter one taller (
?extraHeight=) until they match, so both render the same number of rows. The grids differ by a few px of borders - and by 24px when Infinite Table has no license key and shows its footer. The "settled" metric ignores that footer setting its own inline styles again every second. - Each page loads only its own grid: neither grid is imported in
_app(the Infinite Table license key is set inInfiniteBenchmark.tsx). - String sorting is the
en-US, ASCII case: the sorted string column is lowercase a-z and the browser runs asen-US. Infinite Table compares strings in the order of the browser's locale, AG Grid by character code (the same order for this column). Chrome has a fast path for locale-aware comparison of ASCII text inen-USand a few other locales; in the rest, and with accented text, it is several times slower - so the string result does not carry over to every locale. Inde-DEandro-RO, Infinite Table 10.1.4 is about 5% slower than AG Grid on this sort; from 10.1.5 it uses a reusedIntl.Collatorin those locales and is about 1.2x faster. The number column has no such condition. - Sandboxed Chromium: the benchmark turns Chromium's sandbox on
(Playwright turns it off by default), as in real Chrome. Without it, on
macOS, the first hover recompute after a layout change under the mouse
blocks the main thread for 30-80ms, once per page (
GetCurrentKeyModifiersconnecting to the WindowServer). It showed up as one long frame at the start of the first scroll - only for the grid that updates rows under the mouse first - and does not happen in a sandboxed renderer. - Fixed display scale: Chromium runs with
--force-device-scale-factor=1. The largest element a page can have depends on the scale factor of the display the window is on (about 33.5M px at 1x, 16.7M px at 2x), whatever the emulateddeviceScaleFactor. Pinning it gives both grids the same limit on every machine; the setup fails if their scroll ranges differ. - Statistics: medians, with a 95% bootstrap confidence interval of the ratio of medians (Infinite / AG Grid). A winner is only named when the interval excludes 1. When AG Grid has zeros among its values (0% blank samples, no long frames...), a ratio means nothing - the difference of medians (Infinite − AG Grid) is used instead, and its interval has to exclude 0.
| Variable | Default | |
|---|---|---|
BENCH_SIZES |
1m |
dataset sizes to run |
BENCH_SCENARIOS |
all | comma separated scenario ids, e.g. mount,scroll-jump |
BENCH_RUNS / BENCH_WARMUP |
5 / 1 |
measured / discarded runs per grid per scenario |
BENCH_CPU_THROTTLE |
1 |
CDP CPU throttling rate during measurements |
BENCH_HEADLESS |
off | 1 = Chromium's new headless mode (headed by default - closest to real vsync and GPU) |
BENCH_NO_SANDBOX |
off | 1 = run Chromium without its sandbox (where the sandbox can't start, e.g. some containers) |
BENCH_SCROLL_SPEED / BENCH_SCROLL_DISTANCE |
8000 / 24000 |
wheel gesture (px/s, px) for the smoothness scenarios |
BENCH_FAST_SCROLL_SPEED |
20000 |
the fast gesture of the correctness / screencast scenarios |
BENCH_LOW_UPDATES / BENCH_LOW_UPDATE_ROWS |
5 / 1000 |
low-frequency updates: how many, and the random rows each one changes |
BENCH_LOW_UPDATE_PAUSE |
500 |
ms between an update being painted and the next one |
BENCH_HIGH_UPDATE_RATE |
50 |
high-frequency feed: updates a second |
BENCH_HIGH_UPDATE_ROWS / BENCH_HIGH_UPDATE_SECONDS |
100 / 4 |
the random rows each update of the feed changes, and how long the feed lasts |
BENCH_SAVE_TRACES |
off | 1 = save every trace to benchmark-results/<run id>/traces |
BENCH_VERBOSE |
off | 1 = log the last DOM mutations ("settled") and the first wrong samples of the probes |
BENCH_RUN_ID |
ISO date | results folder name |
BENCH_PORT / BENCH_BASE_URL |
5560 / - |
port of the server the config starts, or an already running server to use instead |
Every scenario has a table with the median (and standard deviation) of each grid, the ratio Infinite / AG Grid, its 95% CI and the "better" grid when the difference is significant. Compare the grids, not the absolute numbers - they depend on the machine, and the screencast in particular adds overhead.