Debian Codegraph @

thirdparty/milvus/internal/core/unittest/bench/bench_naive.cpp

raw
1 // Copyright (C) 2019-2020 Zilliz. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
4 // with the License. You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software distributed under the License
9 // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10 // or implied. See the License for the specific language governing permissions and limitations under the License
11
12 #include <benchmark/benchmark.h>
13 #include <string>
14
15 static void
16 BN_Naive_StringCreation(benchmark::State& state) {
17 for (auto _ : state) std::string empty_string;
18 }
19 // Register the function as a benchmark
20 BENCHMARK(BN_Naive_StringCreation);
21
22 // Define another benchmark
23 static void
24 BN_Naive_StringCopy(benchmark::State& state) {
25 std::string x = "hello";
26 for (auto _ : state) std::string copy(x);
27 }
28 BENCHMARK(BN_Naive_StringCopy);