Skip to content

Commit

Permalink
Add medium_cells benchmark
Browse files Browse the repository at this point in the history
This patch adds a new benchmark which aims at filling a gap between the
`dense_cells` and the `light_cells` benchmarks, providing a more
realistic example of escape sequence density in a normal terminal
workflow.

The new benchmark is an Alacritty ref test recording of a short NeoVim
session, which includes several small and large buffer movements,
different styles of underlines, and window-in-window using a fuzzy
finder and tiled buffers.

This new test intentionally uses a workflow that is pretty escape
sequence heavy, while still being realistic, since workflows without
heavy escape sequence use are already reasonably well covered by the
`light_cells` benchmark.

Closes #40.
  • Loading branch information
chrisduerr authored Dec 25, 2024
1 parent c75155b commit e5e9bf3
Show file tree
Hide file tree
Showing 3 changed files with 423 additions and 2 deletions.
5 changes: 5 additions & 0 deletions benchmarks/medium_cells/benchmark
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

# Write an escape-heavy vim ref test session.

cat "$(dirname $0)/vim_session"
416 changes: 416 additions & 0 deletions benchmarks/medium_cells/vim_session

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl Benchmark {

let mut samples = Vec::new();

let max_samples = max_samples.unwrap_or(usize::max_value());
let max_samples = max_samples.unwrap_or(usize::MAX);
let end = Instant::now() + Duration::from_secs(max_secs);
for _ in (0..max_samples).take_while(|_| Instant::now() < end) {
let duration = self.run_sample(&mut stdout);
Expand Down Expand Up @@ -263,7 +263,7 @@ impl Results {
return 0.;
}

let mean = self.mean() as f64;
let mean = self.mean();
let len = self.samples.len();
self.samples.iter().map(|&s| f64::powi(s as f64 - mean, 2)).sum::<f64>() / (len - 1) as f64
}
Expand Down

0 comments on commit e5e9bf3

Please sign in to comment.