Skip to content

Commit 7e197a5

Browse files
committed
Remove define_benchmarks! macro.
It doesn't make the code any shorter. But it (a) obscures the two-level closure structure, and (b) makes it less clear when things happen.
1 parent c70dc9b commit 7e197a5

File tree

4 files changed

+5
-28
lines changed

4 files changed

+5
-28
lines changed

collector/benchlib/src/benchmark.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,6 @@ impl BenchmarkGroup {
105105
}
106106
}
107107

108-
/// Adds a single benchmark to the benchmark group.
109-
/// ```ignore
110-
/// use benchlib::define_benchmark;
111-
///
112-
/// define_benchmark!(group, my_bench, {
113-
/// || do_something()
114-
/// });
115-
/// ```
116-
#[macro_export]
117-
macro_rules! define_benchmark {
118-
($group:expr, $name:ident, $fun:expr) => {
119-
let func = move || $fun;
120-
$group.register_benchmark(stringify!($name), func);
121-
};
122-
}
123-
124-
pub use define_benchmark;
125-
126108
/// Tests if the name of the benchmark passes through the include and exclude filters.
127109
/// Both filters can contain multiple comma-separated prefixes.
128110
pub fn passes_filter(name: &str, exclude: Option<&str>, include: Option<&str>) -> bool {

collector/runtime-benchmarks/bufreader/src/main.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
use std::io::{BufRead, BufReader, Write};
2-
3-
use snap::{read::FrameDecoder, write::FrameEncoder};
4-
51
use benchlib::benchmark::{black_box, run_benchmark_group};
6-
use benchlib::define_benchmark;
2+
use snap::{read::FrameDecoder, write::FrameEncoder};
3+
use std::io::{BufRead, BufReader, Write};
74

85
const BYTES: usize = 64 * 1024 * 1024;
96

@@ -12,7 +9,7 @@ fn main() {
129
// The pattern we want is a BufReader which wraps a Read impl where one Read::read call will
1310
// never fill the whole BufReader buffer.
1411
run_benchmark_group(|group| {
15-
define_benchmark!(group, bufreader_snappy, {
12+
group.register_benchmark("bufreader_snappy", || {
1613
let data = vec![0u8; BYTES];
1714
move || {
1815
let mut compressed = Vec::new();

collector/runtime-benchmarks/hashmap/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use benchlib;
22
use benchlib::benchmark::run_benchmark_group;
3-
use benchlib::define_benchmark;
43

54
fn main() {
65
run_benchmark_group(|group| {
76
// Measures how long does it take to insert 10 thousand numbers into a `hashbrown` hashmap.
8-
define_benchmark!(group, hashmap_insert_10k, {
7+
group.register_benchmark("hashmap_insert_10k", || {
98
let mut map = hashbrown::HashMap::with_capacity_and_hasher(
109
10000,
1110
fxhash::FxBuildHasher::default(),

collector/runtime-benchmarks/nbody/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
//! Code taken from https://github.com/prestontw/rust-nbody
33
44
use benchlib::benchmark::run_benchmark_group;
5-
use benchlib::define_benchmark;
65

76
mod nbody;
87

98
fn main() {
109
run_benchmark_group(|group| {
11-
define_benchmark!(group, nbody_10k, {
10+
group.register_benchmark("nbody_10k", || {
1211
let mut nbody_10k = nbody::init(10000);
1312
|| {
1413
for _ in 0..10 {

0 commit comments

Comments
 (0)