Add docs on Memory profiling (#1217). (#1319)

This commit is contained in:
Dominic Hamon 2022-01-13 10:19:22 +00:00 committed by GitHub
parent 31e7941796
commit 5531ec80f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,6 +50,8 @@
[Custom Statistics](#custom-statistics)
[Memory Usage](#memory-usage)
[Using RegisterBenchmark](#using-register-benchmark)
[Exiting with an Error](#exiting-with-an-error)
@ -1051,6 +1053,21 @@ BENCHMARK(BM_spin_empty)
->Arg(512);
```
<a name="memory-usage" />
## Memory Usage
It's often useful to also track memory usage for benchmarks, alongside CPU
performance. For this reason, benchmark offers the `RegisterMemoryManager`
method that allows a custom `MemoryManager` to be injected.
If set, the `MemoryManager::Start` and `MemoryManager::Stop` methods will be
called at the start and end of benchmark runs to allow user code to fill out
a report on the number of allocations, bytes used, etc.
This data will then be reported alongside other performance data, currently
only when using JSON output.
<a name="using-register-benchmark" />
## Using RegisterBenchmark(name, fn, args...)