Skip to content

Commit 1a633b0

Browse files
committed
Change terminology
database -> suite suite -> group
1 parent a987f32 commit 1a633b0

File tree

9 files changed

+52
-53
lines changed

9 files changed

+52
-53
lines changed

collector/benchlib/src/benchmark.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use crate::measure::benchmark_function;
55
use crate::process::raise_process_priority;
66
use std::collections::HashMap;
77

8-
/// Create a new benchmark suite. Use the closure argument to define benchmarks.
9-
pub fn benchmark_suite<F: FnOnce(&mut BenchmarkSuite)>(define_func: F) {
8+
/// Create a new benchmark group. Use the closure argument to define benchmarks.
9+
pub fn benchmark_group<F: FnOnce(&mut BenchmarkGroup)>(define_func: F) {
1010
env_logger::init();
1111

12-
let mut suite = BenchmarkSuite::new();
13-
define_func(&mut suite);
14-
suite.run().expect("Benchmark suite has failed");
12+
let mut group = BenchmarkGroup::new();
13+
define_func(&mut group);
14+
group.run().expect("Benchmark group execution has failed");
1515
}
1616

1717
/// Type-erased function that executes a single benchmark.
@@ -22,11 +22,11 @@ struct BenchmarkWrapper {
2222
type BenchmarkMap = HashMap<&'static str, BenchmarkWrapper>;
2323

2424
#[derive(Default)]
25-
pub struct BenchmarkSuite {
25+
pub struct BenchmarkGroup {
2626
benchmarks: BenchmarkMap,
2727
}
2828

29-
impl BenchmarkSuite {
29+
impl BenchmarkGroup {
3030
pub fn new() -> Self {
3131
Self::default()
3232
}
@@ -39,7 +39,7 @@ impl BenchmarkSuite {
3939
constructor: F,
4040
) {
4141
// We want to type-erase the target `func` by wrapping it in a Box.
42-
let benchmark_func = Box::new(move || benchmark_function(name, constructor.clone()));
42+
let benchmark_func = Box::new(move || benchmark_function(constructor.clone()));
4343
let benchmark_def = BenchmarkWrapper {
4444
func: benchmark_func,
4545
};
@@ -48,7 +48,7 @@ impl BenchmarkSuite {
4848
}
4949
}
5050

51-
/// Execute the benchmark suite. It will parse CLI arguments and decide what to do based on
51+
/// Execute the benchmark group. It will parse CLI arguments and decide what to do based on
5252
/// them.
5353
pub fn run(self) -> anyhow::Result<()> {
5454
raise_process_priority();
@@ -100,19 +100,19 @@ fn run_benchmark(args: BenchmarkArgs, benchmarks: BenchmarkMap) -> anyhow::Resul
100100
Ok(())
101101
}
102102

103-
/// Adds a single benchmark to the benchmark suite.
103+
/// Adds a single benchmark to the benchmark group.
104104
/// ```ignore
105105
/// use benchlib::define_benchmark;
106106
///
107-
/// define_benchmark!(suite, my_bench, {
107+
/// define_benchmark!(group, my_bench, {
108108
/// || do_something()
109109
/// });
110110
/// ```
111111
#[macro_export]
112112
macro_rules! define_benchmark {
113-
($suite:expr, $name:ident, $fun:expr) => {
113+
($group:expr, $name:ident, $fun:expr) => {
114114
let func = move || $fun;
115-
$suite.register(stringify!($name), func);
115+
$group.register(stringify!($name), func);
116116
};
117117
}
118118

collector/benchlib/src/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use clap::{FromArgMatches, IntoApp};
22

33
#[derive(clap::Parser, Debug)]
44
pub enum Args {
5-
/// Benchmark all benchmarks in this benchmark suite and print the results as JSON.
5+
/// Benchmark all benchmarks in this benchmark group and print the results as JSON.
66
Benchmark(BenchmarkArgs),
7-
/// List benchmarks that are defined in the current suite as a JSON array.
7+
/// List benchmarks that are defined in the current group as a JSON array.
88
ListBenchmarks,
99
}
1010

collector/benchlib/src/measure/perf_counter/unix.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ struct Counters {
1616
/// The function is executed twice, once to gather wall-time measurement and the second time to
1717
/// gather perf. counters.
1818
pub fn benchmark_function<F: Fn() -> Bench + 'static, R, Bench: FnOnce() -> R + 'static>(
19-
name: &'static str,
2019
benchmark_constructor: F,
2120
) -> anyhow::Result<BenchmarkStats> {
2221
let mut group = create_group()?;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::io::{BufRead, BufReader, Write};
22

33
use snap::{read::FrameDecoder, write::FrameEncoder};
44

5-
use benchlib::benchmark::{benchmark_suite, black_box};
5+
use benchlib::benchmark::{benchmark_group, black_box};
66
use benchlib::define_benchmark;
77

88
const BYTES: usize = 64 * 1024 * 1024;
@@ -11,8 +11,8 @@ fn main() {
1111
// Inspired by https://github.com/rust-lang/rust/issues/102727
1212
// The pattern we want is a BufReader which wraps a Read impl where one Read::read call will
1313
// never fill the whole BufReader buffer.
14-
benchmark_suite(|suite| {
15-
define_benchmark!(suite, bufreader_snappy, {
14+
benchmark_group(|group| {
15+
define_benchmark!(group, bufreader_snappy, {
1616
let data = vec![0u8; BYTES];
1717
move || {
1818
let mut compressed = Vec::new();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use benchlib;
2-
use benchlib::benchmark::benchmark_suite;
2+
use benchlib::benchmark::benchmark_group;
33
use benchlib::define_benchmark;
44

55
fn main() {
6-
benchmark_suite(|suite| {
6+
benchmark_group(|group| {
77
// Measures how long does it take to insert 10 thousand numbers into a `hashbrown` hashmap.
8-
define_benchmark!(suite, hashmap_insert_10k, {
8+
define_benchmark!(group, hashmap_insert_10k, {
99
let mut map = hashbrown::HashMap::with_capacity_and_hasher(
1010
10000,
1111
fxhash::FxBuildHasher::default(),

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//! Calculates the N-body simulation.
22
//! Code taken from https://github.com/prestontw/rust-nbody
33
4-
use benchlib::benchmark::benchmark_suite;
4+
use benchlib::benchmark::benchmark_group;
55
use benchlib::define_benchmark;
66

77
mod nbody;
88

99
fn main() {
10-
benchmark_suite(|suite| {
11-
define_benchmark!(suite, nbody_10k, {
10+
benchmark_group(|group| {
11+
define_benchmark!(group, nbody_10k, {
1212
let mut nbody_10k = nbody::init(10000);
1313
|| {
1414
for _ in 0..10 {

collector/src/runtime/benchmark.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ use core::result::Result::Ok;
66
use std::path::{Path, PathBuf};
77
use std::process::Command;
88

9-
/// A binary that defines several benchmarks using the `benchmark_suite` function from `benchlib`.
9+
/// A binary that defines several benchmarks using the `benchmark_group` function from `benchlib`.
1010
#[derive(Debug)]
11-
pub struct BenchmarkSuite {
11+
pub struct BenchmarkGroup {
1212
pub binary: PathBuf,
1313
pub benchmark_names: Vec<String>,
1414
}
1515

16-
impl BenchmarkSuite {
16+
impl BenchmarkGroup {
1717
pub fn name(&self) -> &str {
1818
self.binary.file_name().unwrap().to_str().unwrap()
1919
}
2020
}
2121

2222
/// A collection of benchmark suites gathered from a directory.
2323
#[derive(Debug)]
24-
pub struct BenchmarkDatabase {
25-
pub suites: Vec<BenchmarkSuite>,
24+
pub struct BenchmarkSuite {
25+
pub groups: Vec<BenchmarkGroup>,
2626
}
2727

28-
impl BenchmarkDatabase {
28+
impl BenchmarkSuite {
2929
pub fn total_benchmark_count(&self) -> u64 {
3030
self.benchmark_names().count() as u64
3131
}
@@ -42,7 +42,7 @@ impl BenchmarkDatabase {
4242
}
4343

4444
fn benchmark_names(&self) -> impl Iterator<Item = &str> {
45-
self.suites
45+
self.groups
4646
.iter()
4747
.flat_map(|suite| suite.benchmark_names.iter().map(|n| n.as_ref()))
4848
}
@@ -63,8 +63,8 @@ impl BenchmarkFilter {
6363
/// We assume that each binary defines a benchmark suite using `benchlib`.
6464
/// We then execute each benchmark suite with the `list-benchmarks` command to find out its
6565
/// benchmark names.
66-
pub fn discover_benchmarks(cargo_stdout: &[u8]) -> anyhow::Result<BenchmarkDatabase> {
67-
let mut binaries = vec![];
66+
pub fn discover_benchmarks(cargo_stdout: &[u8]) -> anyhow::Result<BenchmarkSuite> {
67+
let mut groups = vec![];
6868

6969
for message in Message::parse_stream(cargo_stdout) {
7070
let message = message?;
@@ -79,7 +79,7 @@ pub fn discover_benchmarks(cargo_stdout: &[u8]) -> anyhow::Result<BenchmarkDatab
7979
path.display()
8080
)
8181
})?;
82-
binaries.push(BenchmarkSuite {
82+
groups.push(BenchmarkGroup {
8383
binary: path,
8484
benchmark_names: benchmarks,
8585
});
@@ -90,10 +90,10 @@ pub fn discover_benchmarks(cargo_stdout: &[u8]) -> anyhow::Result<BenchmarkDatab
9090
}
9191
}
9292

93-
binaries.sort_unstable_by(|a, b| a.binary.cmp(&b.binary));
94-
log::debug!("Found binaries: {:?}", binaries);
93+
groups.sort_unstable_by(|a, b| a.binary.cmp(&b.binary));
94+
log::debug!("Found binaries: {:?}", groups);
9595

96-
Ok(BenchmarkDatabase { suites: binaries })
96+
Ok(BenchmarkSuite { groups })
9797
}
9898

9999
/// Uses the `list-benchmarks` command from `benchlib` to find the benchmark names from the given

collector/src/runtime/mod.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@ pub use benchmark::BenchmarkFilter;
1212
/// Perform a series of runtime benchmarks using the provided `rustc` compiler.
1313
/// The runtime benchmarks are looked up in `benchmark_dir`, which is expected to be a path
1414
/// to a Cargo crate. All binaries built by that crate will are expected to be runtime benchmark
15-
/// suites that leverage `benchlib`.
15+
/// groups that leverage `benchlib`.
1616
pub fn bench_runtime(
1717
rustc: &str,
1818
id: Option<&str>,
1919
filter: BenchmarkFilter,
2020
benchmark_dir: PathBuf,
2121
) -> anyhow::Result<()> {
2222
let toolchain = get_local_toolchain(&[Profile::Opt], rustc, None, None, id, "")?;
23-
let output = compile_runtime_benchmarks(&toolchain, &benchmark_dir)?;
24-
let benchmark_db = benchmark::discover_benchmarks(&output)?;
23+
let output = compile_runtime_benchmark_binaries(&toolchain, &benchmark_dir)?;
24+
let suite = benchmark::discover_benchmarks(&output)?;
2525

26-
let total_benchmark_count = benchmark_db.total_benchmark_count();
27-
let filtered = benchmark_db.filtered_benchmark_count(&filter);
26+
let total_benchmark_count = suite.total_benchmark_count();
27+
let filtered = suite.filtered_benchmark_count(&filter);
2828
println!(
2929
"Executing {} benchmarks ({} filtered out)",
3030
filtered,
3131
total_benchmark_count - filtered
3232
);
3333

3434
let mut benchmark_index = 0;
35-
for binary in benchmark_db.suites {
36-
for message in execute_runtime_benchmark(&binary.binary, &filter)? {
35+
for binary in suite.groups {
36+
for message in execute_runtime_benchmark_binary(&binary.binary, &filter)? {
3737
let message = message.map_err(|err| {
3838
anyhow::anyhow!(
3939
"Cannot parse BenchmarkMessage from benchmark {}: {err:?}",
@@ -59,10 +59,10 @@ pub fn bench_runtime(
5959
Ok(())
6060
}
6161

62-
/// Starts executing a single runtime benchmark suite defined in a binary crate located in
63-
/// `runtime-benchmarks`. The binary is expected to use benchlib's `BenchmarkSuite` to execute
62+
/// Starts executing a single runtime benchmark group defined in a binary crate located in
63+
/// `runtime-benchmarks`. The binary is expected to use benchlib's `BenchmarkGroup` to execute
6464
/// a set of runtime benchmarks and print `BenchmarkMessage`s encoded as JSON, one per line.
65-
fn execute_runtime_benchmark(
65+
fn execute_runtime_benchmark_binary(
6666
binary: &Path,
6767
filter: &BenchmarkFilter,
6868
) -> anyhow::Result<impl Iterator<Item = anyhow::Result<BenchmarkMessage>>> {
@@ -92,8 +92,11 @@ fn execute_runtime_benchmark(
9292
Ok(iterator)
9393
}
9494

95-
/// Compiles all runtime benchmarks and returns the stdout output of Cargo.
96-
fn compile_runtime_benchmarks(toolchain: &LocalToolchain, dir: &Path) -> anyhow::Result<Vec<u8>> {
95+
/// Compiles all runtime benchmark binaries (groups) and returns the stdout output of Cargo.
96+
fn compile_runtime_benchmark_binaries(
97+
toolchain: &LocalToolchain,
98+
dir: &Path,
99+
) -> anyhow::Result<Vec<u8>> {
97100
let result = Command::new(&toolchain.cargo)
98101
.env("RUSTC", &toolchain.rustc)
99102
.arg("build")

docs/glossary.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ The following is a glossary of domain specific terminology. Although benchmarks
3636
* **relevant test result comparison**: a test result comparison can be significant but still not be relevant (i.e., worth paying attention to). Relevance is a factor of the test result comparison's significance and magnitude. Comparisons are considered relevant if they are significant and have at least a small magnitude .
3737
* **test result comparison magnitude**: how "large" the delta is between the two test result's under comparison. This is determined by the average of two factors: the absolute size of the change (i.e., a change of 5% is larger than a change of 1%) and the amount above the significance threshold (i.e., a change that is 5x the significance threshold is larger than a change 1.5x the significance threshold).
3838

39-
## Runtime benchmarks
40-
* **benchmark suite**: a collection of individual benchmarks that is defined in a single binary.
41-
4239
## Other
4340

4441
* **bootstrap**: the process of building the compiler from a previous version of the compiler

0 commit comments

Comments
 (0)