[flang][runtime] Make defined formatted I/O process format elementally (#74150)
[llvm-project.git] / libcxx / benchmarks / util_smartptr.bench.cpp
blob053cbd659bef844d8cdaac77dc210c01104d840f
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 #include <memory>
11 #include "benchmark/benchmark.h"
13 static void BM_SharedPtrCreateDestroy(benchmark::State& st) {
14 while (st.KeepRunning()) {
15 auto sp = std::make_shared<int>(42);
16 benchmark::DoNotOptimize(sp.get());
19 BENCHMARK(BM_SharedPtrCreateDestroy);
21 static void BM_SharedPtrIncDecRef(benchmark::State& st) {
22 auto sp = std::make_shared<int>(42);
23 benchmark::DoNotOptimize(sp.get());
24 while (st.KeepRunning()) {
25 std::shared_ptr<int> sp2(sp);
26 benchmark::ClobberMemory();
29 BENCHMARK(BM_SharedPtrIncDecRef);
31 static void BM_WeakPtrIncDecRef(benchmark::State& st) {
32 auto sp = std::make_shared<int>(42);
33 benchmark::DoNotOptimize(sp.get());
34 while (st.KeepRunning()) {
35 std::weak_ptr<int> wp(sp);
36 benchmark::ClobberMemory();
39 BENCHMARK(BM_WeakPtrIncDecRef);
41 BENCHMARK_MAIN();