1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! Benchmarks for `Grid::new`, measuring per-construction cost.
//!
//! retroglyph#264 flags that `Grid::new` pre-allocates a 256-element `Vec<Option<LayerBuf>>` up
//! front, and that `Terminal` holds up to four `Grid`s (`current`, `previous`,
//! `flattened_current`, `flattened_previous`), multiplying that cost. This benchmark measures the
//! cost of constructing a single `Grid`: the dominant cost is the layer-table `Vec` itself, not
//! the grid content, so a range of grid sizes is included to confirm the construction cost is flat
//! with respect to `width`/`height` (only layer 0's `LayerBuf` scales with cell count; the other
//! 255 slots are a fixed-size `Vec` regardless of grid dimensions).
//!
//! Per the issue's explicit "measure before changing" instruction: run this benchmark before and
//! after any change to the layer-table allocation strategy and compare `grid_new/*` timings.
// `criterion_group!`/`criterion_main!` below expand to an undocumented `pub fn benches(..)`; this
// bench binary isn't a published API surface for `missing_docs` to usefully gate.
use ;
use Grid;
use black_box;
/// Registers `Grid::new` construction benchmarks across representative grid sizes.
criterion_group!;
criterion_main!;