diff --git a/core/Cargo.toml b/core/Cargo.toml index 5306737551..4c2fa3df0a 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -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 diff --git a/utils/Cargo.toml b/utils/Cargo.toml index bdd3481a7a..a9e30bc44c 100644 --- a/utils/Cargo.toml +++ b/utils/Cargo.toml @@ -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 @@ -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 } diff --git a/utils/src/bench.rs b/utils/src/bench.rs index db3c836d16..6179e07266 100644 --- a/utils/src/bench.rs +++ b/utils/src/bench.rs @@ -141,10 +141,10 @@ pub fn bench_terms<'r>(rts: Vec>) -> Box }) } -/// 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),