Skip to content

Commit

Permalink
Add pprof feature to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
cydparser committed Aug 8, 2024
1 parent 63f38a8 commit 0fbcf71
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ strsim = "0.10.0"
pretty_assertions.workspace = true
assert_matches.workspace = true
criterion.workspace = true
nickel-lang-utils.workspace = true
nickel-lang-utils = { workspace = true, features = ["pprof"] }
similar.workspace = true
test-generator.workspace = true

Expand Down
5 changes: 4 additions & 1 deletion utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ repository.workspace = true
bench = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
pprof = ["dep:pprof"]

[dependencies]
nickel-lang-core.workspace = true
criterion.workspace = true
Expand All @@ -21,4 +24,4 @@ serde = { workspace = true, features = ["derive"] }
toml = { workspace = true, features = ["parse"] }

[target.'cfg(target_family = "unix")'.dependencies]
pprof = { workspace = true, features = ["criterion", "flamegraph"] }
pprof = { workspace = true, features = ["criterion", "flamegraph"], optional = true }
4 changes: 2 additions & 2 deletions utils/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ pub fn bench_terms<'r>(rts: Vec<Bench<'r>>) -> Box<dyn Fn(&mut Criterion) + 'r>
})
}

/// Create a `Criterion` config. Uses the `PProfProfiler` on Unix systems.
/// Create a `Criterion` config. Uses `PProfProfiler` when `pprof` is enabled on Unix systems.
pub fn criterion_config() -> Criterion {
let config = Criterion::default();
#[cfg(target_family = "unix")]
#[cfg(all(target_family = "unix", feature = "pprof"))]
let config = config.with_profiler(pprof::criterion::PProfProfiler::new(
100,
pprof::criterion::Output::Flamegraph(None),
Expand Down

0 comments on commit 0fbcf71

Please sign in to comment.