`dp` is coming, and then `abs` says which of the two it is not. The component has always been a pixel count, so the name that admits it is the one that leaves room for a second unit beside it. Mechanical: the field on `Len` and `UiScalar`, their constructors, `to_abs`/`get_abs`, the matching WGSL struct member and the locals composing it. Field order and types are unchanged, so the `Pod` layout the shader reads is the same bytes. `f32::abs` is untouched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
44 lines
1.5 KiB
Rust
44 lines
1.5 KiB
Rust
//! What re-placing a subtree costs per frame, as a load for a counter rather
|
|
//! than a check. A span of 200 fixed-height rows, five primitives each, with
|
|
//! the row above them changing height every frame, so every row below is
|
|
//! offered a box the same shape somewhere else.
|
|
//!
|
|
//! cargo test --release --test replace_cost -- --ignored
|
|
//! perf stat -e instructions:u target/release/.../replace_cost-* --ignored
|
|
//!
|
|
//! Wall time is the wrong number here; see `draw_cost.rs`. Measured on
|
|
//! 2026-09-14 at 1.98M instructions per frame, against 2.38M for rewriting
|
|
//! each row's regions instead and 7.13M for redrawing them.
|
|
|
|
use iris::harness::Harness;
|
|
use iris::prelude::*;
|
|
|
|
const ROWS: usize = 200;
|
|
const FRAMES: usize = 200;
|
|
|
|
#[test]
|
|
#[ignore = "measurement, not a check"]
|
|
fn replacing_rows_every_frame() {
|
|
let mut h = Harness::new((1920, 1200));
|
|
let first = rect(Color::RED).height(40).add(&mut h.rsc);
|
|
let mut span = Span::empty(Dir::DOWN);
|
|
span.push(first.add_strong(&mut h.rsc));
|
|
for i in 0..ROWS {
|
|
let row = (
|
|
rect(Color::BLUE.darker(i as f32 / (ROWS * 2) as f32)),
|
|
rect(Color::GREEN).pad(2),
|
|
wtext("row").size(16).pad(2),
|
|
)
|
|
.span(Dir::RIGHT)
|
|
.pad(4)
|
|
.height(40)
|
|
.add(&mut h.rsc);
|
|
span.push(row.add_strong(&mut h.rsc));
|
|
}
|
|
h.set_root(span);
|
|
for i in 0..FRAMES {
|
|
h.rsc[first].y = Some(Len::px(40.0 + (i % 2) as f32));
|
|
h.frame();
|
|
}
|
|
}
|