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//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03
10
11#include <ios>
12#include <locale>
13
14#include <benchmark/benchmark.h>
15
16struct num_put : std::num_put<char, std::string::iterator> {};
17
18template <class T>
19void BM_num_put(benchmark::State& state) {
20 auto val = T(123);
21 std::ios ios(nullptr);
22 num_put np;
23
24 for (auto _ : state) {
25 benchmark::DoNotOptimize(val);
26 std::string str;
27 benchmark::DoNotOptimize(np.put(str.begin(), ios, ' ', val));
28 }
29}
30BENCHMARK(BM_num_put<bool>);
31BENCHMARK(BM_num_put<long>);
32BENCHMARK(BM_num_put<long long>);
33BENCHMARK(BM_num_put<unsigned long>);
34BENCHMARK(BM_num_put<unsigned long long>);
35BENCHMARK(BM_num_put<double>);
36BENCHMARK(BM_num_put<long double>);
37BENCHMARK(BM_num_put<const void*>);
38
39BENCHMARK_MAIN();
40

source code of libcxx/test/benchmarks/locale/num_put.bench.cpp