Lines Matching full:benchmark
25 #include "benchmark/benchmark.h"
33 void BM_StringViewFromString(benchmark::State& state) { in BM_StringViewFromString()
42 benchmark::DoNotOptimize(ps); in BM_StringViewFromString()
43 benchmark::DoNotOptimize(psv); in BM_StringViewFromString()
46 benchmark::DoNotOptimize(sv); in BM_StringViewFromString()
49 BENCHMARK(BM_StringViewFromString)->Arg(12)->Arg(128);
59 void DoEqualityComparisons(benchmark::State& state, absl::string_view a, in DoEqualityComparisons()
62 benchmark::DoNotOptimize(a == b); in DoEqualityComparisons()
66 void BM_EqualIdentical(benchmark::State& state) { in BM_EqualIdentical()
70 BENCHMARK(BM_EqualIdentical)->DenseRange(0, 3)->Range(4, 1 << 10);
72 void BM_EqualSame(benchmark::State& state) { in BM_EqualSame()
77 BENCHMARK(BM_EqualSame)
85 void BM_EqualDifferent(benchmark::State& state) { in BM_EqualDifferent()
94 BENCHMARK(BM_EqualDifferent)->DenseRange(0, 3)->Range(4, 1 << 10);
96 // This benchmark is intended to check that important simplifications can be
104 void DoConstantSizeInlinedEqualityComparisons(benchmark::State& state, in DoConstantSizeInlinedEqualityComparisons()
107 benchmark::DoNotOptimize(a == "aaa"); in DoConstantSizeInlinedEqualityComparisons()
108 benchmark::DoNotOptimize(a == "bbb"); in DoConstantSizeInlinedEqualityComparisons()
109 benchmark::DoNotOptimize(a == "ccc"); in DoConstantSizeInlinedEqualityComparisons()
110 benchmark::DoNotOptimize(a == "ddd"); in DoConstantSizeInlinedEqualityComparisons()
111 benchmark::DoNotOptimize(a == "eee"); in DoConstantSizeInlinedEqualityComparisons()
112 benchmark::DoNotOptimize(a == "fff"); in DoConstantSizeInlinedEqualityComparisons()
113 benchmark::DoNotOptimize(a == "ggg"); in DoConstantSizeInlinedEqualityComparisons()
114 benchmark::DoNotOptimize(a == "hhh"); in DoConstantSizeInlinedEqualityComparisons()
117 void BM_EqualConstantSizeInlined(benchmark::State& state) { in BM_EqualConstantSizeInlined()
121 // We only need to check for size of 3, and <> 3 as this benchmark only has to
123 BENCHMARK(BM_EqualConstantSizeInlined)->DenseRange(2, 4);
125 // This benchmark exists purely to give context to the above timings: this is
129 void DoConstantSizeNonInlinedEqualityComparisons(benchmark::State& state, in DoConstantSizeNonInlinedEqualityComparisons()
133 benchmark::DoNotOptimize(NonInlinedEq(a, "aaa")); in DoConstantSizeNonInlinedEqualityComparisons()
134 benchmark::DoNotOptimize(NonInlinedEq(a, "bbb")); in DoConstantSizeNonInlinedEqualityComparisons()
135 benchmark::DoNotOptimize(NonInlinedEq(a, "ccc")); in DoConstantSizeNonInlinedEqualityComparisons()
136 benchmark::DoNotOptimize(NonInlinedEq(a, "ddd")); in DoConstantSizeNonInlinedEqualityComparisons()
137 benchmark::DoNotOptimize(NonInlinedEq(a, "eee")); in DoConstantSizeNonInlinedEqualityComparisons()
138 benchmark::DoNotOptimize(NonInlinedEq(a, "fff")); in DoConstantSizeNonInlinedEqualityComparisons()
139 benchmark::DoNotOptimize(NonInlinedEq(a, "ggg")); in DoConstantSizeNonInlinedEqualityComparisons()
140 benchmark::DoNotOptimize(NonInlinedEq(a, "hhh")); in DoConstantSizeNonInlinedEqualityComparisons()
144 void BM_EqualConstantSizeNonInlined(benchmark::State& state) { in BM_EqualConstantSizeNonInlined()
148 // We only need to check for size of 3, and <> 3 as this benchmark only has to
150 BENCHMARK(BM_EqualConstantSizeNonInlined)->DenseRange(2, 4);
152 void BM_CompareSame(benchmark::State& state) { in BM_CompareSame()
163 benchmark::DoNotOptimize(a); in BM_CompareSame()
164 benchmark::DoNotOptimize(b); in BM_CompareSame()
165 benchmark::DoNotOptimize(a.compare(b)); in BM_CompareSame()
168 BENCHMARK(BM_CompareSame)->DenseRange(0, 3)->Range(4, 1 << 10);
170 void BM_CompareFirstOneLess(benchmark::State& state) { in BM_CompareFirstOneLess()
179 benchmark::DoNotOptimize(a); in BM_CompareFirstOneLess()
180 benchmark::DoNotOptimize(b); in BM_CompareFirstOneLess()
181 benchmark::DoNotOptimize(a.compare(b)); in BM_CompareFirstOneLess()
184 BENCHMARK(BM_CompareFirstOneLess)->DenseRange(1, 3)->Range(4, 1 << 10);
186 void BM_CompareSecondOneLess(benchmark::State& state) { in BM_CompareSecondOneLess()
195 benchmark::DoNotOptimize(a); in BM_CompareSecondOneLess()
196 benchmark::DoNotOptimize(b); in BM_CompareSecondOneLess()
197 benchmark::DoNotOptimize(a.compare(b)); in BM_CompareSecondOneLess()
200 BENCHMARK(BM_CompareSecondOneLess)->DenseRange(1, 3)->Range(4, 1 << 10);
202 void BM_find_string_view_len_one(benchmark::State& state) { in BM_find_string_view_len_one()
206 benchmark::DoNotOptimize(s.find("x")); // not present; length 1 in BM_find_string_view_len_one()
209 BENCHMARK(BM_find_string_view_len_one)->Range(1, 1 << 20);
211 void BM_find_string_view_len_two(benchmark::State& state) { in BM_find_string_view_len_two()
215 benchmark::DoNotOptimize(s.find("xx")); // not present; length 2 in BM_find_string_view_len_two()
218 BENCHMARK(BM_find_string_view_len_two)->Range(1, 1 << 20);
220 void BM_find_one_char(benchmark::State& state) { in BM_find_one_char()
224 benchmark::DoNotOptimize(s.find('x')); // not present in BM_find_one_char()
227 BENCHMARK(BM_find_one_char)->Range(1, 1 << 20);
229 void BM_rfind_one_char(benchmark::State& state) { in BM_rfind_one_char()
233 benchmark::DoNotOptimize(s.rfind('x')); // not present in BM_rfind_one_char()
236 BENCHMARK(BM_rfind_one_char)->Range(1, 1 << 20);
238 void BM_worst_case_find_first_of(benchmark::State& state, int haystack_len) { in BM_worst_case_find_first_of()
248 benchmark::DoNotOptimize(s.find_first_of(needle)); in BM_worst_case_find_first_of()
252 void BM_find_first_of_short(benchmark::State& state) { in BM_find_first_of_short()
256 void BM_find_first_of_medium(benchmark::State& state) { in BM_find_first_of_medium()
260 void BM_find_first_of_long(benchmark::State& state) { in BM_find_first_of_long()
264 BENCHMARK(BM_find_first_of_short)->DenseRange(0, 4)->Arg(8)->Arg(16)->Arg(32);
265 BENCHMARK(BM_find_first_of_medium)->DenseRange(0, 4)->Arg(8)->Arg(16)->Arg(32);
266 BENCHMARK(BM_find_first_of_long)->DenseRange(0, 4)->Arg(8)->Arg(16)->Arg(32);
272 // This templated benchmark helper function is intended to stress operator== or
279 void StringViewMapBenchmark(benchmark::State& state) { in StringViewMapBenchmark()
334 // Run the benchmark. It includes map construction but is mostly in StringViewMapBenchmark()
346 benchmark::DoNotOptimize(sum); in StringViewMapBenchmark()
350 void BM_StdMap_4(benchmark::State& state) { in BM_StdMap_4()
353 BENCHMARK(BM_StdMap_4)->Range(1 << 10, 1 << 16);
355 void BM_StdMap_8(benchmark::State& state) { in BM_StdMap_8()
358 BENCHMARK(BM_StdMap_8)->Range(1 << 10, 1 << 16);
360 void BM_CopyToStringNative(benchmark::State& state) { in BM_CopyToStringNative()
368 BENCHMARK(BM_CopyToStringNative)->Range(1 << 3, 1 << 12);
370 void BM_AppendToStringNative(benchmark::State& state) { in BM_AppendToStringNative()
379 BENCHMARK(BM_AppendToStringNative)->Range(1 << 3, 1 << 12);