brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · cf48c0b Raw
47 lines · cpp
1 2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10// UNSUPPORTED: c++0311 12#include <ios>13#include <locale>14 15#include <benchmark/benchmark.h>16 17struct num_get : std::num_get<char, std::string::iterator> {};18 19template <class T>20void BM_num_get(benchmark::State& state) {21  auto val = std::string("123");22  std::ios ios(nullptr);23  num_get np;24 25  for (auto _ : state) {26    benchmark::DoNotOptimize(val);27    T out;28    std::ios_base::iostate err = ios.goodbit;29    benchmark::DoNotOptimize(np.get(val.begin(), val.end(), ios, err, out));30    benchmark::DoNotOptimize(out);31  }32}33 34BENCHMARK(BM_num_get<bool>);35BENCHMARK(BM_num_get<long>);36BENCHMARK(BM_num_get<long long>);37BENCHMARK(BM_num_get<unsigned short>);38BENCHMARK(BM_num_get<unsigned int>);39BENCHMARK(BM_num_get<unsigned long>);40BENCHMARK(BM_num_get<unsigned long long>);41BENCHMARK(BM_num_get<float>);42BENCHMARK(BM_num_get<double>);43BENCHMARK(BM_num_get<long double>);44BENCHMARK(BM_num_get<void*>);45 46BENCHMARK_MAIN();47