36#include <benchmark/benchmark.h>
38#include "DGtal/base/Common.h"
39#include "DGtal/kernel/SpaceND.h"
40#include "DGtal/kernel/PointVector.h"
41#include "DGtal/kernel/domains/HyperRectDomain.h"
48 :
public benchmark::Fixture
50 static constexpr std::size_t
dim = 3;
51 static constexpr signed long long int size = 200;
61 , dimensions(
Point::dimension)
63 std::iota(dimensions.begin(), dimensions.end(),
Dimension(0));
68 std::vector<Point::Dimension> dimensions;
72BENCHMARK_DEFINE_F(BenchDomain, DomainTraversal)(benchmark::State& state)
77 for (
auto const& pt :
domain)
79 benchmark::DoNotOptimize(check);
82 state.SetItemsProcessed(
domain.
size() * state.iterations());
85BENCHMARK_DEFINE_F(BenchDomain, DomainReverseTraversal)(benchmark::State& state)
92 benchmark::DoNotOptimize(check);
95 state.SetItemsProcessed(
domain.
size() * state.iterations());
98BENCHMARK_DEFINE_F(BenchDomain, DomainTraversalSubRange)(benchmark::State& state)
105 benchmark::DoNotOptimize(check);
108 state.SetItemsProcessed(
domain.
size() * state.iterations());
111BENCHMARK_DEFINE_F(BenchDomain, DomainReverseTraversalSubRange)(benchmark::State& state)
117 for (
auto it = range.rbegin(), it_end = range.rend(); it != it_end; ++it)
119 benchmark::DoNotOptimize(check);
122 state.SetItemsProcessed(
domain.
size() * state.iterations());
125BENCHMARK_REGISTER_F(BenchDomain, DomainTraversal)->Unit(benchmark::kMillisecond);
126BENCHMARK_REGISTER_F(BenchDomain, DomainReverseTraversal)->Unit(benchmark::kMillisecond);
127BENCHMARK_REGISTER_F(BenchDomain, DomainTraversalSubRange)->Unit(benchmark::kMillisecond);
128BENCHMARK_REGISTER_F(BenchDomain, DomainReverseTraversalSubRange)->Unit(benchmark::kMillisecond);
130int main(
int argc,
char* argv[])
132 benchmark::Initialize(&argc, argv);
133 benchmark::RunSpecifiedBenchmarks();
ConstReverseIterator rbegin() const
ConstSubRange subRange(const std::vector< Dimension > &permutation) const
ConstReverseIterator rend() const
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
DGtal::LinearOperator< Calculus, dim, duality, dim, duality > diagonal(const DGtal::KForm< Calculus, dim, duality > &kform)
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension