forked from OSchip/llvm-project
parent
9a18d55947
commit
0e100998fc
|
@ -7,6 +7,18 @@
|
|||
|
||||
namespace ContainerBenchmarks {
|
||||
|
||||
|
||||
template <class Container, class GenInputs>
|
||||
void BM_ConstructIterIter(benchmark::State& st, Container, GenInputs gen) {
|
||||
auto in = gen(st.range_x());
|
||||
const auto end = in.end();
|
||||
benchmark::DoNotOptimize(&in);
|
||||
while (st.KeepRunning()) {
|
||||
Container c(in.begin(), in.end());
|
||||
benchmark::DoNotOptimize(c.data());
|
||||
}
|
||||
}
|
||||
|
||||
template <class Container, class GenInputs>
|
||||
void BM_InsertValue(benchmark::State& st, Container c, GenInputs gen) {
|
||||
auto in = gen(st.range_x());
|
||||
|
@ -93,7 +105,6 @@ static void BM_FindRehash(benchmark::State& st, Container c, GenInputs gen) {
|
|||
}
|
||||
benchmark::ClobberMemory();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // end namespace ContainerBenchmarks
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
#include <vector>
|
||||
#include <functional>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "benchmark/benchmark_api.h"
|
||||
|
||||
#include "ContainerBenchmarks.hpp"
|
||||
#include "GenerateInput.hpp"
|
||||
|
||||
using namespace ContainerBenchmarks;
|
||||
|
||||
constexpr std::size_t TestNumInputs = 1024;
|
||||
|
||||
BENCHMARK_CAPTURE(BM_ConstructIterIter,
|
||||
vector_char,
|
||||
std::vector<char>{},
|
||||
getRandomIntegerInputs<char>)->Arg(TestNumInputs);
|
||||
|
||||
BENCHMARK_CAPTURE(BM_ConstructIterIter,
|
||||
vector_size_t,
|
||||
std::vector<size_t>{},
|
||||
getRandomIntegerInputs<size_t>)->Arg(TestNumInputs);
|
||||
|
||||
BENCHMARK_CAPTURE(BM_ConstructIterIter,
|
||||
vector_string,
|
||||
std::vector<std::string>{},
|
||||
getRandomStringInputs)->Arg(TestNumInputs);
|
||||
|
||||
|
||||
BENCHMARK_MAIN()
|
Loading…
Reference in New Issue