Start adding benchmarks for vector

llvm-svn: 276552
This commit is contained in:
Eric Fiselier 2016-07-24 06:51:55 +00:00
parent 9a18d55947
commit 0e100998fc
2 changed files with 44 additions and 1 deletions

View File

@ -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

View File

@ -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()