Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions crates/warp_tui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ arboard = { workspace = true }
arboard = { workspace = true, features = ["wayland-data-control"] }

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
tempfile.workspace = true
# `test-util` exposes `Appearance::mock()`, used to register the `Appearance`
# singleton that the editor-backed TUI input view depends on in tests.
Expand All @@ -117,8 +118,14 @@ warp_editor = { workspace = true, features = ["test-util"] }
command.workspace = true
pathfinder_color.workspace = true
warp = { workspace = true, features = ["tui", "test-util"] }
[[bench]]
name = "transcript_bench"
harness = false
required-features = ["test-util"]

[features]
# Exposes deterministic, production-shaped transcript fixtures to benchmarks.
test-util = ["warp/test-util", "warp_core/test-util"]
# Declared so the `warp_channel_config::load_config!` macro's
# `cfg(feature = "release_bundle")` branch is a known cfg in this crate. Today it
# stays off and the local bin uses the runtime generator; wiring the embedded
Expand Down
100 changes: 100 additions & 0 deletions crates/warp_tui/benches/transcript_bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
use std::hint::black_box;
use std::time::Duration;

use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use warp_tui::benchmark_support::{TranscriptBenchmark, TranscriptDataset};

fn benchmark_many_small_blocks(criterion: &mut Criterion) {
let mut group = criterion.benchmark_group("tui_transcript/many_small_blocks");
for blocks in [100, 1_000, 10_000] {
let mut benchmark =
TranscriptBenchmark::new(TranscriptDataset::ManySmallBlocks { blocks }, 120, 50);
group.bench_with_input(
BenchmarkId::new("retained_end_frame", blocks),
&blocks,
|b, _| b.iter(|| black_box(benchmark.present())),
);
benchmark.scroll_to_row(blocks / 2);
group.bench_with_input(
BenchmarkId::new("retained_middle_frame", blocks),
&blocks,
|b, _| b.iter(|| black_box(benchmark.present())),
);
}
group.finish();
}

fn benchmark_long_agent_response(criterion: &mut Criterion) {
let mut group = criterion.benchmark_group("tui_transcript/long_agent_response");
for rows in [1_000, 10_000] {
let mut benchmark =
TranscriptBenchmark::new(TranscriptDataset::LongAgentResponse { rows }, 120, 50);
group.bench_with_input(
BenchmarkId::new("retained_end_frame", rows),
&rows,
|b, _| b.iter(|| black_box(benchmark.present())),
);
benchmark.scroll_to_row(rows / 2);
group.bench_with_input(
BenchmarkId::new("retained_middle_frame", rows),
&rows,
|b, _| b.iter(|| black_box(benchmark.present())),
);
group.bench_with_input(
BenchmarkId::new("invalidated_middle_frame", rows),
&rows,
|b, _| {
b.iter(|| {
benchmark.invalidate_all();
black_box(benchmark.present())
})
},
);
benchmark.scroll_to_end();
}
group.finish();
}

fn benchmark_offscreen_streaming_tail(criterion: &mut Criterion) {
let mut group = criterion.benchmark_group("tui_transcript/offscreen_streaming_tail");
for tail_rows in [1_000, 10_000] {
let mut benchmark = TranscriptBenchmark::new(
TranscriptDataset::OffscreenStreamingTail {
preceding_rows: 100,
tail_rows,
},
120,
50,
);
group.bench_with_input(
BenchmarkId::new("retained_end_frame", tail_rows),
&tail_rows,
|b, _| b.iter(|| black_box(benchmark.present())),
);
benchmark.scroll_to_row(0);
group.bench_with_input(
BenchmarkId::new("dirty_fixed_viewport_frame", tail_rows),
&tail_rows,
|b, _| {
b.iter(|| {
benchmark.invalidate_streaming_tail();
black_box(benchmark.present())
})
},
);
}
group.finish();
}

criterion_group! {
name = benches;
config = Criterion::default()
.sample_size(10)
.warm_up_time(Duration::from_millis(500))
.measurement_time(Duration::from_secs(1));
targets =
benchmark_many_small_blocks,
benchmark_long_agent_response,
benchmark_offscreen_streaming_tail
}
criterion_main!(benches);
Loading
Loading