Skip to content

Commit 3e9c191

Browse files
committed
Move coarse_prof usage behind feature flag
1 parent 183265b commit 3e9c191

7 files changed

Lines changed: 22 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Version 0.3.0
22

3-
- Move `vtkio` convenience trait implementations in `splashsurf_lib` behind a non-default feature flag (flag `vtk-extras`)
3+
- Move `vtkio` convenience trait implementations in `splashsurf_lib` behind a non-default feature flag (flag `vtk-extras`). Flag is enabled in the CLI crate.
4+
- Move `coarse_prof` usage in `splashsurf_lib` behind a non-default feature flag (flag `profiling`). Flag is enabled in the CLI crate.
45

56
## Version 0.2.0
67

splashsurf/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ homepage = "https://github.com/w1th0utnam3/splashsurf"
1313
repository = "https://github.com/w1th0utnam3/splashsurf"
1414

1515
[dependencies]
16-
splashsurf_lib = { path = "../splashsurf_lib", version = "0.2", features = ["vtk_extras"] }
16+
splashsurf_lib = { path = "../splashsurf_lib", version = "0.2", features = ["vtk_extras", "profiling"] }
1717
structopt = "0.3"
1818
log = "0.4"
1919
fern = "0.6"

splashsurf_lib/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ exclude = [
2121
[features]
2222
default = []
2323
vtk_extras = ["vtkio"]
24+
profiling = ["coarse-prof"]
2425

2526
[dependencies]
2627
log = "0.4"
2728
nalgebra = "0.23"
2829
num = "0.3"
2930
anyhow = "1.0"
3031
thiserror = "1.0"
31-
coarse-prof = "0.2"
32+
coarse-prof = { version = "0.2", optional = true }
3233
itertools = "0.9"
3334
rayon = "1.5"
3435
dashmap = "3.11"

splashsurf_lib/src/density_map.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use coarse_prof::profile;
21
use dashmap::ReadOnlyView as ReadDashMap;
32
use log::{info, warn};
43
use nalgebra::Vector3;

splashsurf_lib/src/lib.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
/// Re-export the version of nalgebra used by this crate
66
pub use nalgebra;
77

8+
#[cfg(feature = "profiling")]
9+
/// Invokes coarse_prof::profile! with the given expression
10+
macro_rules! profile {
11+
($body:expr) => {
12+
coarse_prof::profile!($body);
13+
};
14+
}
15+
16+
#[cfg(not(feature = "profiling"))]
17+
/// No-op macro if profiling is disabled
18+
macro_rules! profile {
19+
($body:expr) => {
20+
$body
21+
};
22+
}
23+
824
mod aabb;
925
/// Computation of sparse density maps (evaluation of particle densities and mapping onto sparse grids)
1026
pub mod density_map;
@@ -27,7 +43,6 @@ pub use density_map::DensityMap;
2743
pub use numeric_types::{Index, Real, ThreadSafe};
2844
pub use uniform_grid::{GridConstructionError, UniformGrid};
2945

30-
use coarse_prof::profile;
3146
use log::info;
3247
use mesh::TriMesh3d;
3348
use nalgebra::Vector3;
@@ -89,6 +104,7 @@ pub struct Parameters<R: Real> {
89104
pub enable_multi_threading: bool,
90105
}
91106

107+
/// Macro version of Option::map that allows using e.g. using the ?-operator in the map expression
92108
macro_rules! map_option {
93109
($some_optional:expr, $value_identifier:ident => $value_transformation:expr) => {
94110
match $some_optional {

splashsurf_lib/src/marching_cubes.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use coarse_prof::profile;
21
use log::info;
32
use nalgebra::Vector3;
43

splashsurf_lib/src/neighborhood_search.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use coarse_prof::profile;
21
use nalgebra::Vector3;
32
use rayon::prelude::*;
43

0 commit comments

Comments
 (0)