Skip to content

Commit d525802

Browse files
feat: use the same uri scheme for walltime and intrumented
1 parent ff6f4b3 commit d525802

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

crates/divan_compat/divan_fork/src/divan.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ impl Divan {
311311
if should_compute_stats {
312312
let stats = bench_context.compute_stats();
313313
{
314+
// WARNING: Keep in sync with `codspeed-divan-compat::uri::generate`
315+
// Not worth doing the work of actually using the same code since this fork
316+
// is temporary
314317
let name = bench_entry.display_name().to_string();
315318
let file = bench_entry.meta().location.file;
316319
let mut module_path = bench_entry

crates/divan_compat/src/compat/entry.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ pub struct EntryMeta {
5656
pub bench_options: Option<LazyLock<BenchOptions>>,
5757
}
5858

59+
impl EntryMeta {
60+
#[inline]
61+
pub(crate) fn module_path_components<'a>(&self) -> impl Iterator<Item = &'a str> {
62+
self.module_path.split("::")
63+
}
64+
}
65+
5966
/// Where an entry is located.
6067
#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord)]
6168
#[allow(missing_docs)]

crates/divan_compat/src/compat/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub mod __private {
1111

1212
mod bench;
1313
mod entry;
14+
mod uri;
1415
mod util;
1516

1617
pub use bench::*;
@@ -31,13 +32,7 @@ pub fn main() {
3132

3233
// 4. Scan the tree and execute benchmarks
3334
for entry in bench_entries.iter() {
34-
let entry_uri = format!(
35-
"{}:{}::{}::{}",
36-
entry.meta.location.file,
37-
entry.meta.location.line,
38-
entry.meta.module_path,
39-
entry.meta.display_name,
40-
);
35+
let entry_uri = uri::generate(entry.meta.display_name, &entry.meta);
4136

4237
if let Some(options) = &entry.meta.bench_options.as_ref() {
4338
if let Some(true) = options.ignore {

crates/divan_compat/src/compat/uri.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use crate::__private::EntryMeta;
2+
3+
pub(crate) fn generate(
4+
bench_display_name: impl std::fmt::Display,
5+
bench_meta: &EntryMeta,
6+
) -> String {
7+
let file = bench_meta.location.file;
8+
let mut module_path = bench_meta
9+
.module_path_components()
10+
.skip(1)
11+
.collect::<Vec<_>>()
12+
.join("::");
13+
if !module_path.is_empty() {
14+
module_path.push_str("::");
15+
}
16+
let uri = format!("{file}::{module_path}{bench_display_name}");
17+
18+
uri
19+
}

0 commit comments

Comments
 (0)