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"
43 using namespace DGtal;
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;
72 BENCHMARK_DEFINE_F(BenchDomain, DomainTraversal)(benchmark::State& state)
77 for (
auto const& pt :
domain)
79 benchmark::DoNotOptimize(check);
82 state.SetItemsProcessed(
domain.
size() * state.iterations());
85 BENCHMARK_DEFINE_F(BenchDomain, DomainReverseTraversal)(benchmark::State& state)
92 benchmark::DoNotOptimize(check);
95 state.SetItemsProcessed(
domain.
size() * state.iterations());
98 BENCHMARK_DEFINE_F(BenchDomain, DomainTraversalSubRange)(benchmark::State& state)
105 benchmark::DoNotOptimize(check);
108 state.SetItemsProcessed(
domain.
size() * state.iterations());
111 BENCHMARK_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());
125 BENCHMARK_REGISTER_F(BenchDomain, DomainTraversal)->Unit(benchmark::kMillisecond);
126 BENCHMARK_REGISTER_F(BenchDomain, DomainReverseTraversal)->Unit(benchmark::kMillisecond);
127 BENCHMARK_REGISTER_F(BenchDomain, DomainTraversalSubRange)->Unit(benchmark::kMillisecond);
128 BENCHMARK_REGISTER_F(BenchDomain, DomainReverseTraversalSubRange)->Unit(benchmark::kMillisecond);
130 int 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
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
int main(int argc, char **argv)
unsigned int dim(const Vector &z)