From b6f91bef0f77e98edccbf828fce45a1fca7ef657 Mon Sep 17 00:00:00 2001 From: toluschr Date: Sun, 20 Oct 2024 15:56:22 +0200 Subject: [PATCH 1/3] Fix incorrect shebang /bin/sh for bash scripts --- benchmarks/cursor_motion/benchmark | 2 +- benchmarks/dense_cells/benchmark | 2 +- benchmarks/dense_cells/setup | 2 +- benchmarks/light_cells/benchmark | 2 +- benchmarks/light_cells/setup | 2 +- benchmarks/scrolling/benchmark | 2 +- benchmarks/scrolling/setup | 2 +- benchmarks/scrolling_bottom_region/setup | 2 +- benchmarks/scrolling_bottom_small_region/setup | 2 +- benchmarks/scrolling_fullscreen/benchmark | 2 +- benchmarks/scrolling_fullscreen/setup | 2 +- benchmarks/scrolling_top_region/setup | 2 +- benchmarks/scrolling_top_small_region/setup | 2 +- benchmarks/unicode/benchmark | 2 +- benchmarks/unicode/setup | 2 +- extra_benchmarks/missing/benchmark | 2 +- extra_benchmarks/missing/setup | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/benchmarks/cursor_motion/benchmark b/benchmarks/cursor_motion/benchmark index 0015e2e..f17c59b 100755 --- a/benchmarks/cursor_motion/benchmark +++ b/benchmarks/cursor_motion/benchmark @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Move cursor around for every single write. diff --git a/benchmarks/dense_cells/benchmark b/benchmarks/dense_cells/benchmark index fca319e..acd4754 100755 --- a/benchmarks/dense_cells/benchmark +++ b/benchmarks/dense_cells/benchmark @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Update the entire grid as often as possible with a huge payload in every cell. diff --git a/benchmarks/dense_cells/setup b/benchmarks/dense_cells/setup index 1d03c92..5f6e9cc 100755 --- a/benchmarks/dense_cells/setup +++ b/benchmarks/dense_cells/setup @@ -1,3 +1,3 @@ -#!/bin/sh +#!/bin/bash printf "\e[?1049h" diff --git a/benchmarks/light_cells/benchmark b/benchmarks/light_cells/benchmark index 7304ddc..e259633 100755 --- a/benchmarks/light_cells/benchmark +++ b/benchmarks/light_cells/benchmark @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Update the entire grid as often as possible without scrolling. diff --git a/benchmarks/light_cells/setup b/benchmarks/light_cells/setup index 1d03c92..5f6e9cc 100755 --- a/benchmarks/light_cells/setup +++ b/benchmarks/light_cells/setup @@ -1,3 +1,3 @@ -#!/bin/sh +#!/bin/bash printf "\e[?1049h" diff --git a/benchmarks/scrolling/benchmark b/benchmarks/scrolling/benchmark index 87fa3e8..6821c71 100755 --- a/benchmarks/scrolling/benchmark +++ b/benchmarks/scrolling/benchmark @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Scroll all lines up as quickly as possible. diff --git a/benchmarks/scrolling/setup b/benchmarks/scrolling/setup index b388e65..86ca648 100755 --- a/benchmarks/scrolling/setup +++ b/benchmarks/scrolling/setup @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash for _ in {0..100000}; do printf "y\n" diff --git a/benchmarks/scrolling_bottom_region/setup b/benchmarks/scrolling_bottom_region/setup index 13d6e0d..e522685 100755 --- a/benchmarks/scrolling_bottom_region/setup +++ b/benchmarks/scrolling_bottom_region/setup @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash tty="/dev/$(ps -o tty= -p $$)" lines=$(tput lines < $tty) diff --git a/benchmarks/scrolling_bottom_small_region/setup b/benchmarks/scrolling_bottom_small_region/setup index 5f8c7b9..1e34b9a 100755 --- a/benchmarks/scrolling_bottom_small_region/setup +++ b/benchmarks/scrolling_bottom_small_region/setup @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash tty="/dev/$(ps -o tty= -p $$)" lines=$(tput lines < $tty) diff --git a/benchmarks/scrolling_fullscreen/benchmark b/benchmarks/scrolling_fullscreen/benchmark index c514631..4112e80 100755 --- a/benchmarks/scrolling_fullscreen/benchmark +++ b/benchmarks/scrolling_fullscreen/benchmark @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Scroll all lines up with every line completely filled. diff --git a/benchmarks/scrolling_fullscreen/setup b/benchmarks/scrolling_fullscreen/setup index b388e65..86ca648 100755 --- a/benchmarks/scrolling_fullscreen/setup +++ b/benchmarks/scrolling_fullscreen/setup @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash for _ in {0..100000}; do printf "y\n" diff --git a/benchmarks/scrolling_top_region/setup b/benchmarks/scrolling_top_region/setup index 11ecc0a..dd63584 100755 --- a/benchmarks/scrolling_top_region/setup +++ b/benchmarks/scrolling_top_region/setup @@ -1,3 +1,3 @@ -#!/bin/sh +#!/bin/bash printf "\e[?1049h\e[2;$(tput lines)r" diff --git a/benchmarks/scrolling_top_small_region/setup b/benchmarks/scrolling_top_small_region/setup index 1c62dcf..3d810a6 100755 --- a/benchmarks/scrolling_top_small_region/setup +++ b/benchmarks/scrolling_top_small_region/setup @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash tty="/dev/$(ps -o tty= -p $$)" lines=$(tput lines < $tty) diff --git a/benchmarks/unicode/benchmark b/benchmarks/unicode/benchmark index c378c47..72f0657 100755 --- a/benchmarks/unicode/benchmark +++ b/benchmarks/unicode/benchmark @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Write a ton of different unicode symbols. diff --git a/benchmarks/unicode/setup b/benchmarks/unicode/setup index 1d03c92..5f6e9cc 100755 --- a/benchmarks/unicode/setup +++ b/benchmarks/unicode/setup @@ -1,3 +1,3 @@ -#!/bin/sh +#!/bin/bash printf "\e[?1049h" diff --git a/extra_benchmarks/missing/benchmark b/extra_benchmarks/missing/benchmark index 5efdb1a..748ad2f 100755 --- a/extra_benchmarks/missing/benchmark +++ b/extra_benchmarks/missing/benchmark @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Print a lot of "missing" glyphs. diff --git a/extra_benchmarks/missing/setup b/extra_benchmarks/missing/setup index 1d03c92..5f6e9cc 100755 --- a/extra_benchmarks/missing/setup +++ b/extra_benchmarks/missing/setup @@ -1,3 +1,3 @@ -#!/bin/sh +#!/bin/bash printf "\e[?1049h" From 9db239f52c6172740da4485cb51381e471e473fb Mon Sep 17 00:00:00 2001 From: toluschr Date: Sun, 20 Oct 2024 16:20:45 +0200 Subject: [PATCH 2/3] Add benchmark whitelist flag --- src/bench.rs | 15 +++++++++------ src/cli.rs | 5 +++++ src/main.rs | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/bench.rs b/src/bench.rs index 115479e..3f48d52 100644 --- a/src/bench.rs +++ b/src/bench.rs @@ -31,7 +31,7 @@ impl Display for Error { } /// Find all benchmarks recursively in the specified location. -pub fn find_benchmarks(paths: &[PathBuf]) -> Vec { +pub fn find_benchmarks(paths: &[PathBuf], names: &Vec) -> Vec { let mut benchmarks: HashMap, Option)> = HashMap::new(); for path in paths { @@ -47,11 +47,14 @@ pub fn find_benchmarks(paths: &[PathBuf]) -> Vec { if let Some(name) = path.parent().and_then(|path| path.file_name()) { let name = name.to_string_lossy().to_string(); - let bench = benchmarks.entry(name).or_default(); - match file_name.as_str() { - "setup" => bench.0 = Some(path), - "benchmark" => bench.1 = Some(path), - _ => unreachable!(), + + if names.len() == 0 || names.contains(&name) { + let bench = benchmarks.entry(name).or_default(); + match file_name.as_str() { + "setup" => bench.0 = Some(path), + "benchmark" => bench.1 = Some(path), + _ => unreachable!(), + } } } } diff --git a/src/cli.rs b/src/cli.rs index 7c916dd..4be4779 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,6 +1,7 @@ //! CLI argument parsing. use std::path::PathBuf; +use std::string::String; use clap::Parser; @@ -15,6 +16,10 @@ pub struct Config { #[clap(short, long, value_name = "DIRECTORY", default_value = "./benchmarks")] pub benchmarks: Vec, + /// Benchmark name. + #[clap(short, long, value_name = "WHITELIST")] + pub whitelist: Vec, + /// Number of warmup iterations. #[clap(long, value_name = "NUM", default_value = "1")] pub warmup: usize, diff --git a/src/main.rs b/src/main.rs index 04d3bec..604c945 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ fn main() { let config = Config::parse(); // Find all available benchmarks. - let mut loaders = bench::find_benchmarks(&config.benchmarks); + let mut loaders = bench::find_benchmarks(&config.benchmarks, &config.whitelist); // Run all benchmarks one at a time. let results: Vec = loaders From bc891c0255c095bbf976a04aa5cc8143ad397cb1 Mon Sep 17 00:00:00 2001 From: toluschr Date: Sun, 20 Oct 2024 16:39:52 +0200 Subject: [PATCH 3/3] Add benchmark pan_up_fullscreen --- benchmarks/pan_up_fullscreen/benchmark | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 benchmarks/pan_up_fullscreen/benchmark diff --git a/benchmarks/pan_up_fullscreen/benchmark b/benchmarks/pan_up_fullscreen/benchmark new file mode 100755 index 0000000..6edc36c --- /dev/null +++ b/benchmarks/pan_up_fullscreen/benchmark @@ -0,0 +1,7 @@ +#!/bin/bash + +tty="/dev/$(ps -o tty= -p $$)" +columns=$(tput cols < $tty) +lines=$(tput lines < $tty) + +printf "\e[${lines}T"