Skip to content

Commit 8247987

Browse files
Merge pull request #1261 from lplewa/peak_fragmentation
disable fragmentation output for peak benchmark
2 parents 6b3a124 + 931bcb8 commit 8247987

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

benchmark/benchmark.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ class multiple_malloc_free_benchmark : public benchmark_interface<Size, Alloc> {
303303
typename std::vector<next_alloc_data>::const_iterator;
304304
std::vector<std::unique_ptr<next_alloc_data_iterator>> next_iter;
305305
int64_t iterations;
306+
bool log_fragmentation;
307+
multiple_malloc_free_benchmark(bool log_fragmentation = true)
308+
: log_fragmentation(log_fragmentation) {}
306309

307310
public:
308311
void SetUp(::benchmark::State &state) override {
@@ -350,7 +353,7 @@ class multiple_malloc_free_benchmark : public benchmark_interface<Size, Alloc> {
350353
void TearDown(::benchmark::State &state) override {
351354
base::allocator.postBench(state);
352355
auto tid = state.thread_index();
353-
if (tid == 0) {
356+
if (tid == 0 && log_fragmentation) {
354357
size_t current_memory_allocated = 0;
355358
for (const auto &allocationsPerThread : allocations) {
356359
for (const auto &allocation : allocationsPerThread) {
@@ -517,7 +520,12 @@ template <
517520
std::enable_if_t<std::is_base_of<allocator_interface, Alloc>::value>>
518521
class peak_alloc_benchmark
519522
: public multiple_malloc_free_benchmark<Size, Alloc> {
523+
520524
using base = multiple_malloc_free_benchmark<Size, Alloc>;
525+
526+
public:
527+
peak_alloc_benchmark() : base(false) {}
528+
521529
virtual void prepareWorkload(benchmark::State &state) override {
522530
// Retrieve the thread index and corresponding operation buffer.
523531
auto tid = state.thread_index();

0 commit comments

Comments
 (0)