From 5531ec80f78536c87bd66a4ae40f5eb59c687eed Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Thu, 13 Jan 2022 10:19:22 +0000 Subject: [PATCH] Add docs on Memory profiling (#1217). (#1319) --- docs/user_guide.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/user_guide.md b/docs/user_guide.md index b86ef432..919e0f0c 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -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); ``` + + +## 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. + ## Using RegisterBenchmark(name, fn, args...)