You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
libcxx
benchmarks
CMakeLists.txt
ContainerBenchmarks.hpp
GenerateInput.hpp
algorithms.bench.cpp
filesystem.bench.cpp
string.bench.cpp
stringstream.bench.cpp
unordered_set_operations.bench.cpp
util_smartptr.bench.cpp
vector_operations.bench.cpp
cmake
docs
fuzzing
include
lib
src
utils
www
.arcconfig
.clang-format
.gitignore
CMakeLists.txt
CREDITS.TXT
LICENSE.TXT
NOTES.TXT
TODO.TXT
appveyor-reqs-install.cmd
appveyor.yml
libcxxabi
libunwind
lld
lldb
llvm
openmp
polly
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mk
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
114 lines
3.3 KiB
C++
114 lines
3.3 KiB
C++
#ifndef BENCHMARK_CONTAINER_BENCHMARKS_HPP
|
|
#define BENCHMARK_CONTAINER_BENCHMARKS_HPP
|
|
|
|
#include <cassert>
|
|
|
|
#include "benchmark/benchmark_api.h"
|
|
|
|
namespace ContainerBenchmarks {
|
|
|
|
|
|
template <class Container, class GenInputs>
|
|
void BM_ConstructIterIter(benchmark::State& st, Container, GenInputs gen) {
|
|
auto in = gen(st.range(0));
|
|
const auto begin = in.begin();
|
|
const auto end = in.end();
|
|
benchmark::DoNotOptimize(&in);
|
|
while (st.KeepRunning()) {
|
|
Container c(begin, 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(0));
|
|
const auto end = in.end();
|
|
while (st.KeepRunning()) {
|
|
c.clear();
|
|
for (auto it = in.begin(); it != end; ++it) {
|
|
benchmark::DoNotOptimize(&(*c.insert(*it).first));
|
|
}
|
|
benchmark::ClobberMemory();
|
|
}
|
|
}
|
|
|
|
template <class Container, class GenInputs>
|
|
void BM_InsertValueRehash(benchmark::State& st, Container c, GenInputs gen) {
|
|
auto in = gen(st.range(0));
|
|
const auto end = in.end();
|
|
while (st.KeepRunning()) {
|
|
c.clear();
|
|
c.rehash(16);
|
|
for (auto it = in.begin(); it != end; ++it) {
|
|
benchmark::DoNotOptimize(&(*c.insert(*it).first));
|
|
}
|
|
benchmark::ClobberMemory();
|
|
}
|
|
}
|
|
|
|
|
|
template <class Container, class GenInputs>
|
|
void BM_InsertDuplicate(benchmark::State& st, Container c, GenInputs gen) {
|
|
auto in = gen(st.range(0));
|
|
const auto end = in.end();
|
|
c.insert(in.begin(), in.end());
|
|
benchmark::DoNotOptimize(&c);
|
|
benchmark::DoNotOptimize(&in);
|
|
while (st.KeepRunning()) {
|
|
for (auto it = in.begin(); it != end; ++it) {
|
|
benchmark::DoNotOptimize(&(*c.insert(*it).first));
|
|
}
|
|
benchmark::ClobberMemory();
|
|
}
|
|
}
|
|
|
|
|
|
template <class Container, class GenInputs>
|
|
void BM_EmplaceDuplicate(benchmark::State& st, Container c, GenInputs gen) {
|
|
auto in = gen(st.range(0));
|
|
const auto end = in.end();
|
|
c.insert(in.begin(), in.end());
|
|
benchmark::DoNotOptimize(&c);
|
|
benchmark::DoNotOptimize(&in);
|
|
while (st.KeepRunning()) {
|
|
for (auto it = in.begin(); it != end; ++it) {
|
|
benchmark::DoNotOptimize(&(*c.emplace(*it).first));
|
|
}
|
|
benchmark::ClobberMemory();
|
|
}
|
|
}
|
|
|
|
template <class Container, class GenInputs>
|
|
static void BM_Find(benchmark::State& st, Container c, GenInputs gen) {
|
|
auto in = gen(st.range(0));
|
|
c.insert(in.begin(), in.end());
|
|
benchmark::DoNotOptimize(&(*c.begin()));
|
|
const auto end = in.data() + in.size();
|
|
while (st.KeepRunning()) {
|
|
for (auto it = in.data(); it != end; ++it) {
|
|
benchmark::DoNotOptimize(&(*c.find(*it)));
|
|
}
|
|
benchmark::ClobberMemory();
|
|
}
|
|
}
|
|
|
|
template <class Container, class GenInputs>
|
|
static void BM_FindRehash(benchmark::State& st, Container c, GenInputs gen) {
|
|
c.rehash(8);
|
|
auto in = gen(st.range(0));
|
|
c.insert(in.begin(), in.end());
|
|
benchmark::DoNotOptimize(&(*c.begin()));
|
|
const auto end = in.data() + in.size();
|
|
while (st.KeepRunning()) {
|
|
for (auto it = in.data(); it != end; ++it) {
|
|
benchmark::DoNotOptimize(&(*c.find(*it)));
|
|
}
|
|
benchmark::ClobberMemory();
|
|
}
|
|
}
|
|
|
|
} // end namespace ContainerBenchmarks
|
|
|
|
#endif // BENCHMARK_CONTAINER_BENCHMARKS_HPP
|