use thag_profiler::debug_log;
#[cfg(feature = "full_profiling")]
use thag_profiler::{profiling::ProfileType, safe_alloc, warn_once};
#[test]
#[cfg(feature = "full_profiling")]
fn test_example_function_with_warn_once() {
safe_alloc! {
thag_profiler::profiling::set_global_profile_type(ProfileType::Time);
example_function_with_warn_once();
example_function_with_warn_once();
example_function_with_warn_once();
thag_profiler::profiling::set_global_profile_type(ProfileType::Memory);
example_function_with_warn_once();
};
}
#[cfg(feature = "full_profiling")]
fn example_function_with_warn_once() {
debug_log!("Entering example function");
let profile_type = thag_profiler::get_global_profile_type();
let is_mem_prof = profile_type == ProfileType::Memory || profile_type == ProfileType::Both;
warn_once!(
!is_mem_prof,
|| {
debug_log!(
"Example: Skipping processing because profile_type={:?}",
profile_type
);
},
return
);
debug_log!("Example: Running actual processing code");
}
#[test]
fn test_refactored_record_dealloc() {
debug_log!("This is just an example - the actual implementation would need to be done in mem_tracking.rs");
}