stats_alloc_helper
A crate that provides a helper to measure memory allocations in tests.
Example
To allow measuring allocations, you must use the provided LockedAllocator
,
because otherwise tests running in other thread could mess up the numbers.
Typically this means a setup similar to the following in tests:
use System;
use ;
use ;
static GLOBAL: = new;
// In the actual tests:
let mut length = 0;
let stats = memory_measured;
assert_eq!;
assert_eq!;
Async futures are supported with async_tokio
feature enabled:
async
This is achieved by creating a separate single threaded runtime on a separate thread and driving the future to completion on it.
See crate's tests for more examples.