I am profiling a bigger application and switching relatively often between profiled/non-profiled and have a working checkout of the code with dhat profiling inserted into many submodules of a bigger workspace. I created a macro to print the current memory stats across a bunch of different functions and lines of code. In the macro I get the heap stats via HeapStats::get(), but this is problematic and fails if I don't have the profiler enabled. Since this macro is for testing copy pasted in a few crates it's quite annoying to toggle it via feature flag (the feature flag would need to be passed down from the binary crate) and it's also annoying to comment out the code everytime I toggle the profiling.
It would be nice if there was a way to check if profiling is enabled, or if HeapStats::get had a variant which returned Option<HeapStats> or Result<HeapStats, SomeError>.
I am not sure what your preferred API surface for this is, if you have any ideas/recommendations I can draft the PR for it.
I am profiling a bigger application and switching relatively often between profiled/non-profiled and have a working checkout of the code with
dhat
profiling inserted into many submodules of a bigger workspace. I created a macro to print the current memory stats across a bunch of different functions and lines of code. In the macro I get the heap stats viaHeapStats::get()
, but this is problematic and fails if I don't have the profiler enabled. Since this macro is for testing copy pasted in a few crates it's quite annoying to toggle it via feature flag (the feature flag would need to be passed down from the binary crate) and it's also annoying to comment out the code everytime I toggle the profiling.It would be nice if there was a way to check if profiling is enabled, or if
HeapStats::get
had a variant which returnedOption<HeapStats>
orResult<HeapStats, SomeError>
.I am not sure what your preferred API surface for this is, if you have any ideas/recommendations I can draft the PR for it.