From 0af8191532b8e6545a6f4342a47a0dd2457360ff Mon Sep 17 00:00:00 2001 From: Pascal Seitz Date: Mon, 20 May 2024 15:48:21 +0800 Subject: [PATCH] remove unused input name --- Cargo.toml | 2 +- benches/bench_group.rs | 9 +++++---- src/bench_group.rs | 14 ++++++-------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1f38c0f..789fcbf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "binggan" -version = "0.7.0" +version = "0.8.0" authors = ["Pascal Seitz "] edition = "2021" homepage = "https://github.com/pseitz/binggan" diff --git a/benches/bench_group.rs b/benches/bench_group.rs index 8a3d03b..1b89004 100644 --- a/benches/bench_group.rs +++ b/benches/bench_group.rs @@ -37,17 +37,18 @@ fn run_bench() { runner.config().enable_perf(); runner.config().set_cache_trasher(true); - let mut group = runner.new_group(); for (input_name, data) in inputs.iter() { + let mut group = runner.new_group(); + group.set_name(input_name); group.set_input_size(data.len() * std::mem::size_of::()); - group.register_with_input("vec", input_name, data, move |data| { + group.register_with_input("vec", data, move |data| { black_box(test_vec(data)); }); - group.register_with_input("hashmap", input_name, data, move |data| { + group.register_with_input("hashmap", data, move |data| { black_box(test_hashmap(data)); }); + group.run(); } - group.run(); } fn main() { diff --git a/src/bench_group.rs b/src/bench_group.rs index 197288a..d95d647 100644 --- a/src/bench_group.rs +++ b/src/bench_group.rs @@ -50,35 +50,33 @@ impl<'a> BenchGroup<'a> { self.input_size_in_bytes = Some(input_size); } - /// Register a benchmark with the given name and function. + /// Register a benchmark with the given name, function and input. pub fn register_with_input>( &mut self, bench_name: S, - input_name: S, input: &'a I, fun: F, ) where F: Fn(&'a I) + 'static, { let name = bench_name.into(); - let input_name = input_name.into(); let bench = NamedBench::new(name, Box::new(fun)); self.register_named_with_input( bench, NamedInput { - name: Cow::Owned(input_name), + name: Cow::Borrowed(""), data: input, }, ); } /// Register a benchmark with the given name and function. - pub fn register>(&mut self, name: S, fun: F) + pub fn register>(&mut self, bench_name: S, fun: F) where F: Fn(&'a ()) + 'static, { - let name = name.into(); + let name = bench_name.into(); let bench = NamedBench::new(name, Box::new(fun)); self.register_named_with_input(bench, EMPTY_INPUT); @@ -109,8 +107,8 @@ impl<'a> BenchGroup<'a> { /// Set the name of the group. /// The name is printed before the benchmarks are run. /// It is also used to distinguish when writing the results to disk. - pub fn set_name>(&mut self, name: S) { - self.name = Some(name.into()); + pub fn set_name>(&mut self, name: S) { + self.name = Some(name.as_ref().into()); } /// Run the benchmarks and report the results.