Skip to content

Commit

Permalink
remove unused input name
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz committed May 20, 2024
1 parent 8d96660 commit 0af8191
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "binggan"
version = "0.7.0"
version = "0.8.0"
authors = ["Pascal Seitz <[email protected]>"]
edition = "2021"
homepage = "https://github.com/pseitz/binggan"
Expand Down
9 changes: 5 additions & 4 deletions benches/bench_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<usize>());
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() {
Expand Down
14 changes: 6 additions & 8 deletions src/bench_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<I, F, S: Into<String>>(
&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<I, F, S: Into<String>>(&mut self, name: S, fun: F)
pub fn register<I, F, S: Into<String>>(&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);
Expand Down Expand Up @@ -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<S: Into<String>>(&mut self, name: S) {
self.name = Some(name.into());
pub fn set_name<S: AsRef<str>>(&mut self, name: S) {
self.name = Some(name.as_ref().into());
}

/// Run the benchmarks and report the results.
Expand Down

0 comments on commit 0af8191

Please sign in to comment.