Skip to content

Commit f3d7310

Browse files
committed
feat: add support for analysis mode
1 parent 874abd6 commit f3d7310

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

crates/codspeed/src/codspeed.rs

Lines changed: 7 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,16 @@ 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()
59+
.set_executed_benchmark(&self.current_benchmark.to_string_lossy());
5560
self.benchmarked
5661
.push(self.current_benchmark.to_str().unwrap().to_string());
5762
let action_str = if self.is_instrumented {

crates/codspeed/src/measurement.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@ use std::ffi::CString;
22

33
use crate::request::{send_client_request, ClientRequest, Value};
44

5-
#[inline(always)]
6-
pub fn is_instrumented() -> bool {
7-
let valgrind_depth = unsafe {
8-
send_client_request(
9-
0,
10-
&[ClientRequest::RunningOnValgrind as Value, 0, 0, 0, 0, 0],
11-
)
12-
};
13-
valgrind_depth > 0
14-
}
15-
165
#[inline(always)]
176
pub fn set_metadata() {
187
let full_metadata = CString::new(format!(

crates/codspeed/src/request/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const CG_BASE: u32 = ((b'C' as u32) << 24) + ((b'T' as u32) << 16);
33
#[allow(non_camel_case_types)]
44
#[repr(u32)]
55
pub enum ClientRequest {
6-
RunningOnValgrind = 0x1001,
76
ZeroStatistics = CG_BASE + 1,
87
DumpStatisticsAt = CG_BASE + 3,
98
StartInstrumentation = CG_BASE + 4,

0 commit comments

Comments
 (0)