[MemProf] Templatize CallStackRadixTreeBuilder (NFC) (#117014)
[llvm-project.git] / libcxx / test / benchmarks / monotonic_buffer.bench.cpp
blob66ab5809985b5be963b693922e584bec4cce6841
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
11 #include <list>
12 #include <memory_resource>
14 #include "benchmark/benchmark.h"
16 static void bm_list(benchmark::State& state) {
17 char buffer[16384];
18 std::pmr::monotonic_buffer_resource resource(buffer, sizeof(buffer));
19 for (auto _ : state) {
20 std::pmr::list<int> l(&resource);
21 for (int64_t i = 0; i != state.range(); ++i) {
22 l.push_back(1);
23 benchmark::DoNotOptimize(l);
25 resource.release();
28 BENCHMARK(bm_list)->Range(1, 2048);
30 BENCHMARK_MAIN();