Skip to content

Commit 0ba2272

Browse files
committed
feat(codspeed): add instrument-hooks
1 parent 420302d commit 0ba2272

File tree

10 files changed

+321
-260
lines changed

10 files changed

+321
-260
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
[submodule "crates/divan_compat/examples/src/the_algorithms/Rust"]
33
path = crates/divan_compat/examples/src/the_algorithms/Rust
44
url = https://github.com/TheAlgorithms/Rust.git
5+
[submodule "crates/codspeed/instrument-hooks"]
6+
path = crates/codspeed/instrument-hooks
7+
url = https://github.com/CodSpeedHQ/instrument-hooks

Cargo.lock

Lines changed: 105 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/codspeed/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ keywords = ["codspeed", "benchmark"]
1919

2020
[dependencies]
2121
anyhow = { workspace = true }
22-
bincode = "1.3.3"
2322
colored = "2.0.0"
2423
glob = "0.3.2"
2524
libc = "^0.2"
26-
nix = { version = "0.29.0", features = ["fs"] }
25+
nix = { version = "0.30.1", features = ["time"] }
2726
serde = { workspace = true }
2827
serde_json = { workspace = true }
2928
statrs = { version = "0.18.0", default-features = false }
@@ -35,3 +34,7 @@ harness = false
3534

3635
[dev-dependencies]
3736
tempfile = { workspace = true }
37+
38+
[build-dependencies]
39+
bindgen = "0.72.1"
40+
cc = "1.0"

crates/codspeed/build.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use std::{env, path::PathBuf};
2+
3+
fn main() {
4+
// Compile the C library
5+
cc::Build::new()
6+
.file("instrument-hooks/dist/core.c")
7+
.include("instrument-hooks/includes")
8+
.flag("-w") // Suppress all warnings
9+
.compile("instrument_hooks");
10+
11+
let bindings = bindgen::Builder::default()
12+
.header("instrument-hooks/includes/core.h")
13+
// Tell cargo to invalidate the built crate whenever any of the
14+
// included header files changed.
15+
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
16+
.generate()
17+
.expect("Unable to generate bindings");
18+
19+
// Write the bindings to the $OUT_DIR/bindings.rs file.
20+
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
21+
bindings
22+
.write_to_file(out_path.join("bindings.rs"))
23+
.expect("Couldn't write bindings!");
24+
}

crates/codspeed/instrument-hooks

Submodule instrument-hooks added at 0d3de57

0 commit comments

Comments
 (0)