Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:59

0001 #include <benchmark/benchmark.h>
0002 static void BM_StringCreation(benchmark::State& state) {
0003   for (auto _ : state)
0004     std::string empty_string;
0005 }
0006 
0007 // Register the function as a benchmark
0008 BENCHMARK(BM_StringCreation);
0009 
0010 // Define another benchmark
0011 static void BM_StringCopy(benchmark::State& state) {
0012   std::string x = "hello";
0013   for (auto _ : state)
0014     std::string copy(x);  // NOLINT - prevent clang-tidy from changing to a `const &`
0015 }
0016 BENCHMARK(BM_StringCopy);
0017 
0018 BENCHMARK_MAIN();