How to benchmark memory usage of a function?

后端 未结 4 530
情话喂你
情话喂你 2021-01-01 14:07

I notice that Rust\'s test has a benchmark mode that will measure execution time in ns/iter, but I could not find a way to measure memory usage.

How wou

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-01 14:57

    Currently, the only way to get allocation information is the alloc::heap::stats_print(); method (behind #![feature(alloc)]), which calls jemalloc's print_stats().

    I'll update this answer with further information once I have learned what the output means.

    (Note that I'm not going to accept this answer, so if someone comes up with a better solution...)

提交回复
热议问题