Is there a tool in Rust to count the number of allocations in a test?


Hi! I was curious if there was a tool in Rust one could use to track the number of allocations in a test? For example, the Golang testing package has a function ReportAllocs that will return malloc statistics for a test case, and I was curious if there was perhaps a similar tool in Rust for gathering jemalloc statistics when running tests. Heapsize looks very promising, but from what I can tell its intended to be used with whole program as opposed to single functions or tests. Not sure if there’s a tool out of there looking to tackle smaller tasks like tests. Thanks!


I’m not super familiar with it, but Linux perf has support for Rust, it can track allocations and I think you can group them by function.

There’s cargo-profiler as a frontend for valgrind (at others in the future), but that’s in its infancy.


Awesome! I’ll have to check them out. Thanks for the pointers.