Memory benchmarking?

Hello,

I have some difficulties to find a benchmark tool for memory usage in Rust.
Ideally I'm searching for a crate that is able to measure :

  • memory usage
  • CPU real time
  • CPU elapsed time
    Note: I'm on Linux

The fact that I don't find one is maybe due to a silly idea I have (?) Or maybe because the better way is to implement measure points by myself ? (doesn't seem complicated...)

Open to your advice and suggestions.

memory usage

i assume if you're benchmarking memory usage you also want to debug it (e.g. figure out what is responsible for all the allocations)
dhat - Rust can help with both.

i'd also recommend rerunning all benchmarks with alternative allocators (tcmalloc, mimalloc, jemalloc, etc), i remember drastically reducing the memory usage in one of my projects by using a different allocator.

The crate divan might be helpful for you. It provides features for both runtime and memory performance, and it is very easy to use.

Thanks you @miro and @HeMel
@miro : dhat seems to be a powerfull tool to track memory usage. I note it! Thanks!

@HeMel : You are right! Thanks! It make the job simply by adding the following lines :

#[global_allocator]
static ALLOC: AllocProfiler = AllocProfiler::system();

just make sure to remove them in release builds