Files
improvise/benches
Edward Langley 8a4ee06570 bench: measure grid_of's whole-grid cost, and decline the narrowing it was for
improvise-i5tk's acceptance criterion 1 was a benchmark, on the ground that "this
can dominate TUI rendering" is exactly as unevidenced as "it is fine".
benches/grid_projection.rs is that benchmark, and it says no.

One grid_of call, dense pivot grids, this machine:

  typical                  100 x  4 =   400 cells  whole-grid   1.902ms  ratio 1.2x  col_widths 45%
  large                   1200 x  8 =  9600 cells  whole-grid 185.644ms  ratio 1.3x  col_widths 64%
  18k cells (gotcha 41)   3000 x  6 = 18000 cells  whole-grid 402.435ms  ratio 1.5x  col_widths 42%
  pathological            9000 x 10 = 90000 cells  whole-grid   5.235s   ratio 1.5x  col_widths 44%

ratio is whole-grid over a 45x12 terminal window: 1.2-1.5x, against a fix whose
stated cost is changing what a cache index MEANS in the TUI and putting every
scroll site in scope. Wrong trade, so i5tk is closed on the measurement.

Why the ratio is so low is the bigger finding. Two of the three whole-grid passes
a frame performs are viewport-independent by construction:
ui/viewport.rs::compute_col_widths takes no viewport and walks every (row, col)
twice -- once for cell text, once for the column totals it must also size -- and a
column total must sum every row including scrolled-past ones (gotcha 44).
grid_of's own cell_display loop is the third pass and the only one windowing would
touch. So the whole grid is evaluated about three times per frame, every result
discarded, and at 18,000 cells a keypress costs four tenths of a second. Filed as
improvise-jmjz; its fix is caching or one fused pass, which this benchmark has now
distinguished from the windowing it rules out.

No criterion crate: plain Instant, and test = false so cargo test does not run a
target that takes seconds by design.

Closes improvise-i5tk

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-20 11:07:30 -07:00
..