Skip to content

Commit 19d4905

Browse files
committed
feat(divan_fork): add the codspeed walltime collection point
1 parent 31712b9 commit 19d4905

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/divan_compat/divan_fork/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ cfg-if = "1"
2020
clap = { version = "4", default-features = false, features = ["std", "env"] }
2121
condtype = "1.3"
2222
regex = { package = "regex-lite", version = "0.1", default-features = false, features = ["std", "string"] }
23+
codspeed = { path = "../../codspeed", version = "=2.8.0-alpha.0" }
2324

2425
[target.'cfg(unix)'.dependencies]
2526
libc = "0.2.148"

crates/divan_compat/divan_fork/src/bench/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ pub(crate) struct BenchContext<'a> {
529529
pub thread_count: NonZeroUsize,
530530

531531
/// Recorded samples.
532-
samples: SampleCollection,
532+
pub samples: SampleCollection,
533533

534534
/// Per-iteration counters grouped by sample.
535535
counters: CounterCollection,

crates/divan_compat/divan_fork/src/divan.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,32 @@ impl Divan {
310310

311311
if should_compute_stats {
312312
let stats = bench_context.compute_stats();
313+
{
314+
let name = bench_entry.display_name().to_string();
315+
let file = bench_entry.meta().location.file;
316+
let module_path = bench_entry
317+
.meta()
318+
.module_path_components()
319+
.collect::<Vec<_>>()
320+
.join("::");
321+
let uri = format!("{file}::{module_path}::{name}");
322+
let iter_per_round = bench_context.samples.sample_size;
323+
let times_ns: Vec<_> = bench_context
324+
.samples
325+
.time_samples
326+
.iter()
327+
.map(|s| s.duration.picos / 1_000)
328+
.collect();
329+
let max_time_ns = options.max_time.map(|t| t.as_nanos());
330+
::codspeed::walltime::collect_raw_walltime_results(
331+
"divan",
332+
name,
333+
uri,
334+
iter_per_round,
335+
max_time_ns,
336+
times_ns,
337+
);
338+
};
313339
tree_painter.borrow_mut().finish_leaf(
314340
is_last_thread_count,
315341
&stats,

0 commit comments

Comments
 (0)