Skip to content

Commit 3470ff8

Browse files
committed
chore: wip [skip ci]
1 parent 9181bce commit 3470ff8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

crates/codspeed/src/codspeed.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::measurement;
1+
use crate::{instrument_hooks::InstrumentHooks, measurement};
22
use colored::Colorize;
33
use std::ffi::CString;
44

@@ -19,7 +19,8 @@ pub struct CodSpeed {
1919

2020
impl CodSpeed {
2121
pub fn new() -> Self {
22-
let is_instrumented = measurement::is_instrumented();
22+
let ih = InstrumentHooks::instance();
23+
let is_instrumented = ih.is_instrumented();
2324
if !is_instrumented {
2425
println!(
2526
"{} codspeed is enabled, but no performance measurement will be made since it's running in an unknown environment.",
@@ -46,12 +47,17 @@ impl CodSpeed {
4647
#[inline(always)]
4748
pub fn start_benchmark(&mut self, name: &str) {
4849
self.current_benchmark = CString::new(name).expect("CString::new failed");
50+
let _ = InstrumentHooks::instance().start_benchmark();
4951
measurement::start();
5052
}
5153

5254
#[inline(always)]
5355
pub fn end_benchmark(&mut self) {
5456
measurement::stop(&self.current_benchmark);
57+
let _ = InstrumentHooks::instance().stop_benchmark();
58+
let _ = InstrumentHooks::instance().set_executed_benchmark(
59+
&self.current_benchmark.to_string_lossy()
60+
);
5561
self.benchmarked
5662
.push(self.current_benchmark.to_str().unwrap().to_string());
5763
let action_str = if self.is_instrumented {

0 commit comments

Comments
 (0)