How to benchmark memory usage of a function?
You can use the jemalloc allocator to print the allocation statistics. For example, Cargo.toml: [package] name = “stackoverflow-30869007” version = “0.1.0” edition = “2018” [dependencies] jemallocator = “0.5” jemalloc-sys = {version = “0.5”, features = [“stats”]} libc = “0.2” src/main.rs: use libc::{c_char, c_void}; use std::ptr::{null, null_mut}; #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; extern “C” fn … Read more