Skip to content

Commit 651c501

Browse files
authored
chore: turn off profiling by default (#842)
1 parent 5ee076a commit 651c501

7 files changed

Lines changed: 30 additions & 10 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ homepage.workspace = true
7777
authors.workspace = true
7878

7979
[features]
80-
default = ["logging", "progress_bar", "profiling"]
80+
default = ["logging", "progress_bar"]
8181

8282
logging = ["log4rs", "fern", "wasm-bindgen", "web-sys"]
8383
progress_bar = ["dep:progress_bar", "anyhow"]

docs/book/src/examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Demonstrates the profiling module: counting events, opening spans, computing
2929
statistics, and writing profiling data to JSON.
3030

3131
```sh
32-
cargo run --example profiling
32+
cargo run --example profiling --features profiling
3333
```
3434

3535
## End-to-end Examples

docs/book/src/topics/profiling-module.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ Ixa includes a lightweight, feature-gated profiling module you can use to:
88
- Write results to a JSON file along with execution statistics
99

1010
The API lives under `ixa::profiling` and is behind the `profiling` Cargo feature
11-
(enabled by default). If you disable the feature, the API becomes a no-op so you
12-
can leave profiling calls in your code.
11+
(disabled by default). If you do not enable the feature, the API becomes a no-op
12+
so you can leave profiling calls in your code.
13+
14+
When running the built-in profiling example from the root crate, enable the
15+
feature explicitly:
16+
17+
```sh
18+
cargo run --example profiling --features profiling
19+
```
1320

1421
## Example console output
1522

examples/profiling/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ authors.workspace = true
1010
publish = false
1111

1212
[dependencies]
13-
ixa = { path = "../../" }
13+
ixa = { path = "../../", features = ["profiling"] }
1414
serde_json.workspace = true
1515

1616
[lints]

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//!
3232
//! - **`logging`**: enables structured logging for native and wasm targets.
3333
//! - **`progress_bar`**: enables the timeline progress bar for long-running simulations.
34-
//! - **`profiling`**: enables collection and reporting of execution profiling statistics.
34+
//! - **`profiling`**: enables collection and reporting of execution profiling statistics. Disabled by default.
3535
3636
#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/docs/book/src/cli-usage.md"))]
3737

src/profiling/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! - Computed statistics – define custom, derived metrics over collected data.
1111
//! - A default computed statistic, infection forecasting efficiency.
1212
//!
13-
//! Feature flag: all functionality is gated behind the `profiling` feature (enabled by default).
13+
//! Feature flag: all functionality is gated behind the `profiling` feature (disabled by default).
1414
//! When the feature is disabled, the public API remains available but becomes a no-op and gets
1515
//! optimized away by the compiler, so you can leave profiling calls in your code at zero cost.
1616
//!
@@ -173,7 +173,7 @@ pub use reporting::*;
173173

174174
use crate::{error, Context, ContextReportExt};
175175

176-
#[cfg(test)]
176+
#[cfg(all(test, feature = "profiling"))]
177177
/// Publicly expose access to profiling data only for testing.
178178
pub fn get_profiling_data() -> std::sync::MutexGuard<'static, ProfilingData> {
179179
profiling_data()

src/profiling/reporting.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ pub trait ProfilingContextExt: ContextReportExt {
5151
}
5252
impl ProfilingContextExt for Context {}
5353

54-
#[cfg(test)]
55-
mod tests {
54+
#[cfg(all(test, feature = "profiling"))]
55+
mod profiling_tests {
5656
use std::fs;
5757
use std::time::Duration;
5858

@@ -183,3 +183,16 @@ mod tests {
183183
);
184184
}
185185
}
186+
187+
#[cfg(test)]
188+
mod tests {
189+
use super::ProfilingContextExt;
190+
use crate::context::Context;
191+
192+
#[test]
193+
fn context_implements_profiling_extension() {
194+
let mut context = Context::new();
195+
context.print_execution_statistics(false);
196+
context.write_profiling_data();
197+
}
198+
}

0 commit comments

Comments
 (0)