This patch removes some of the benchmarks in our suite that are
relatively low value. Specifically:
- `lexicographical_compare` isn't benchmarked with every number of
elements between 1 and 8 anymore
- `bitset` isn't benchmarked with as many sizes anymore. Instead, only
some representative sizes are benchmarked.
- `to_chars` isn't benchmarked for every possible base anymore, but only
2, 8, 10, 16 and 23 (so we have an uncommon base as well)
47 lines
1.8 KiB
C++
Executable File
47 lines
1.8 KiB
C++
Executable File
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// UNSUPPORTED: c++03, c++11, c++14, c++17
|
|
|
|
#include <algorithm>
|
|
#include <benchmark/benchmark.h>
|
|
#include <vector>
|
|
|
|
// Benchmarks the worst case: check the whole range just to find out that they compare equal
|
|
template <class T>
|
|
static void bm_lexicographical_compare(benchmark::State& state) {
|
|
std::vector<T> vec1(state.range(), '1');
|
|
std::vector<T> vec2(state.range(), '1');
|
|
|
|
for (auto _ : state) {
|
|
benchmark::DoNotOptimize(vec1);
|
|
benchmark::DoNotOptimize(vec2);
|
|
benchmark::DoNotOptimize(std::lexicographical_compare(vec1.begin(), vec1.end(), vec2.begin(), vec2.end()));
|
|
}
|
|
}
|
|
BENCHMARK(bm_lexicographical_compare<unsigned char>)->Arg(1)->Range(8, 1 << 20);
|
|
BENCHMARK(bm_lexicographical_compare<signed char>)->Arg(1)->Range(8, 1 << 20);
|
|
BENCHMARK(bm_lexicographical_compare<int>)->Arg(1)->Range(8, 1 << 20);
|
|
|
|
template <class T>
|
|
static void bm_ranges_lexicographical_compare(benchmark::State& state) {
|
|
std::vector<T> vec1(state.range(), '1');
|
|
std::vector<T> vec2(state.range(), '1');
|
|
|
|
for (auto _ : state) {
|
|
benchmark::DoNotOptimize(vec1);
|
|
benchmark::DoNotOptimize(vec2);
|
|
benchmark::DoNotOptimize(std::ranges::lexicographical_compare(vec1.begin(), vec1.end(), vec2.begin(), vec2.end()));
|
|
}
|
|
}
|
|
BENCHMARK(bm_ranges_lexicographical_compare<unsigned char>)->Arg(1)->Range(8, 1 << 20);
|
|
BENCHMARK(bm_ranges_lexicographical_compare<signed char>)->Arg(1)->Range(8, 1 << 20);
|
|
BENCHMARK(bm_ranges_lexicographical_compare<int>)->Arg(1)->Range(8, 1 << 20);
|
|
|
|
BENCHMARK_MAIN();
|