| 1 |
use std::sync::LazyLock; |
| 2 |
|
| 3 |
use crate::bench::BenchOptions; |
| 4 |
|
| 5 |
/// Metadata common to `#[divan::bench]` and `#[divan::bench_group]`. |
| 6 |
pub struct EntryMeta { |
| 7 |
/// The entry's display name. |
| 8 |
pub display_name: &'static str, |
| 9 |
|
| 10 |
/// The entry's original name. |
| 11 |
/// |
| 12 |
/// This is used to find a `GroupEntry` for a `BenchEntry`. |
| 13 |
pub raw_name: &'static str, |
| 14 |
|
| 15 |
/// The entry's raw `module_path!()`. |
| 16 |
pub module_path: &'static str, |
| 17 |
|
| 18 |
/// Where the entry was defined. |
| 19 |
pub location: EntryLocation, |
| 20 |
|
| 21 |
/// Configures the benchmarker via attribute options. |
| 22 |
pub bench_options: Option<LazyLock<BenchOptions<'static>>>, |
| 23 |
} |
| 24 |
|
| 25 |
/// Where an entry is located. |
| 26 |
#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord)] |
| 27 |
#[allow(missing_docs)] |
| 28 |
pub struct EntryLocation { |
| 29 |
pub file: &'static str, |
| 30 |
pub line: u32, |
| 31 |
pub col: u32, |
| 32 |
} |
| 33 |
|
| 34 |
impl EntryMeta { |
| 35 |
#[inline] |
| 36 |
pub(crate) fn bench_options(&self) -> Option<&BenchOptions<'_>> { |
| 37 |
self.bench_options.as_deref() |
| 38 |
} |
| 39 |
|
| 40 |
#[inline] |
| 41 |
pub(crate) fn module_path_components<'a>(&self) -> impl Iterator<Item = &'a str> { |
| 42 |
self.module_path.split("::") |
| 43 |
} |
| 44 |
} |