Skip to content

Commit

Permalink
Update display format for typing_latency.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
YizhePKU committed Oct 21, 2024
1 parent d32c3b5 commit 07f11a5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions examples/typing_latency.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//! Measure the typing latency of Reedline with default configurations.
//!
//! The result is not accurate on Windows, since alacritty has very bad latency
//! response on Windows due to the way it implemented async-IO without IOCP.
use alacritty_test::{pty_spawn, PtyExt, Terminal};
use reedline::{DefaultPrompt, Reedline, Signal};
Expand Down Expand Up @@ -52,11 +55,13 @@ fn main() -> std::io::Result<()> {
break;
}
}
total_latency += start_time.elapsed();
let latency = start_time.elapsed();
total_latency += latency;

println!(
"single keystroke latency = {:.2}ms, averaging over {loop_cnt} iterations",
(total_latency.as_millis() as f64) / (loop_cnt as f64),
"single keystroke latency = {:.2}ms, average latency = {:.2}ms over {loop_cnt} iterations",
(latency.as_millis() as f64),
(total_latency.as_millis() as f64) / (loop_cnt as f64)
);

// delete the keystroke
Expand Down

0 comments on commit 07f11a5

Please sign in to comment.