use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::thread;
#[doc(hidden)]
pub fn get_heap_ptr_if_trackable<T>(_value: &T) -> Option<usize> {
None
}
#[doc(hidden)]
pub fn hash_thread_id() -> u64 {
let thread_id = thread::current().id();
let thread_id_str = format!("{:?}", thread_id);
let mut hasher = DefaultHasher::new();
thread_id_str.hash(&mut hasher);
hasher.finish()
}
#[macro_export]
macro_rules! memscope_summary {
() => {
let summary = $crate::facade::compat::get_memory_summary();
println!("Memory Summary:");
println!(" Total Allocations: {}", summary.total_allocations);
println!(" Active Allocations: {}", summary.active_allocations);
println!(" Current Memory: {} bytes", summary.current_memory);
println!(" Peak Memory: {} bytes", summary.peak_memory);
println!(" Thread Count: {}", summary.thread_count);
};
}
#[macro_export]
macro_rules! show_top_allocations {
($limit:expr) => {
let allocations = $crate::facade::compat::get_top_allocations($limit);
println!("Top {} Allocations by Size:", $limit);
for (i, alloc) in allocations.iter().enumerate() {
println!(" {}. {} bytes at {:x}", i + 1, alloc.size, alloc.ptr);
}
};
}
#[macro_export]
macro_rules! export_memory_json {
($verbose:expr) => {
match $crate::facade::compat::export_json($verbose) {
Ok(json) => {
println!("Memory data exported to JSON:");
println!("{}", json);
}
Err(e) => {
eprintln!("Failed to export memory data: {}", e);
}
}
};
}
#[cfg(test)]
mod tests {
#[test]
fn test_memscope_summary_macro_compiles() {
}
}