CppBenchmark  1.0.4.0
C++ Benchmark Library
containers.cpp

Containers push back benchmark

//
// Created by Ivan Shynkarenka on 18.07.2015
//
#include <deque>
#include <list>
#include <vector>
template <typename T>
class ContainerFixture : public virtual CppBenchmark::Fixture
{
protected:
T container;
void Initialize(CppBenchmark::Context& context) override { container = T(); }
void Cleanup(CppBenchmark::Context& context) override { container.clear(); }
};
BENCHMARK_FIXTURE(ContainerFixture<std::list<int>>, "std::list<int>.push_back()")
{
container.push_back(0);
}
BENCHMARK_FIXTURE(ContainerFixture<std::vector<int>>, "std::vector<int>.push_back()")
{
container.push_back(0);
}
BENCHMARK_FIXTURE(ContainerFixture<std::deque<int>>, "std::deque<int>.push_back()")
{
container.push_back(0);
}
Benchmark running context.
Definition: context.h:27
Benchmark fixture.
Definition: fixture.h:21
virtual void Initialize(Context &context)
Initialize benchmark.
Definition: fixture.h:38
virtual void Cleanup(Context &context)
Cleanup benchmark.
Definition: fixture.h:45
CppBenchmark definitions.
#define BENCHMARK_FIXTURE(fixture,...)
Benchmark with fixture register macro.
Definition: cppbenchmark.h:128
#define BENCHMARK_MAIN()
Benchmark main entry point macro.
Definition: cppbenchmark.h:46