Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/benches/src/lib.rs
6592 views
1
/// Automatically generates the qualified name of a benchmark given its function name and module
2
/// path.
3
///
4
/// This macro takes a single string literal as input and returns a [`&'static str`](str). Its
5
/// result is determined at compile-time. If you need to create variations of a benchmark name
6
/// based on its input, use this in combination with [`BenchmarkId`](criterion::BenchmarkId).
7
///
8
/// # When to use this
9
///
10
/// Use this macro to name benchmarks that are not within a group and benchmark groups themselves.
11
/// You'll most commonly use this macro with:
12
///
13
/// - [`Criterion::bench_function()`](criterion::Criterion::bench_function)
14
/// - [`Criterion::bench_with_input()`](criterion::Criterion::bench_with_input)
15
/// - [`Criterion::benchmark_group()`](criterion::Criterion::benchmark_group)
16
///
17
/// You do not want to use this macro with
18
/// [`BenchmarkGroup::bench_function()`](criterion::BenchmarkGroup::bench_function) or
19
/// [`BenchmarkGroup::bench_with_input()`](criterion::BenchmarkGroup::bench_with_input), because
20
/// the group they are in already has the qualified path in it.
21
///
22
/// # Example
23
///
24
/// ```
25
/// mod ecs {
26
/// mod query {
27
/// use criterion::Criterion;
28
/// use benches::bench;
29
///
30
/// fn iter(c: &mut Criterion) {
31
/// // Benchmark name ends in `ecs::query::iter`.
32
/// c.bench_function(bench!("iter"), |b| {
33
/// // ...
34
/// });
35
/// }
36
/// }
37
/// }
38
/// ```
39
#[macro_export]
40
macro_rules! bench {
41
($name:literal) => {
42
concat!(module_path!(), "::", $name)
43
};
44
}
45
46