DGtal 1.3.0
Loading...
Searching...
No Matches
benchmarkHyperRectDomain-catch.cpp
1
32#include <iostream>
33#include <numeric>
34#include <chrono>
35
36#include "DGtal/base/Common.h"
37#include "DGtal/kernel/SpaceND.h"
38#include "DGtal/kernel/PointVector.h"
39#include "DGtal/kernel/domains/HyperRectDomain.h"
40
41#include "DGtalCatch.h"
42
43using namespace DGtal;
44using namespace std;
45
46// Context for each benchmark
47struct BenchDomain
48{
49 static constexpr std::size_t dim = 3;
50 static constexpr signed long long int size = 200;
51
53 using Point = Space::Point;
55
56 BenchDomain()
57 : a(Point::diagonal(0))
58 , b(Point::diagonal(size))
59 , domain(Domain(a, b))
60 , dimensions(Point::dimension)
61 {
62 std::iota(dimensions.begin(), dimensions.end(), Dimension(0));
63 }
64
65 Point a, b;
67 std::vector<Point::Dimension> dimensions;
68};
69
70
71TEST_CASE_METHOD(BenchDomain, "Benchmarking HyperRectDomain iterators using Catch2", "[catch]")
72{
73 BENCHMARK("Domain traversal")
74 {
75 Point check;
76
77 for (auto const& pt : domain)
78 check += pt;
79
80 return check;
81 };
82
83 BENCHMARK("Domain reverse traversal")
84 {
85 Point check;
86
87 for (auto it = domain.rbegin(), it_end = domain.rend(); it != it_end; ++it)
88 check += *it;
89
90 return check;
91 };
92
93 BENCHMARK("Domain traversal using subRange")
94 {
95 Point check;
96
97 for (auto const& pt : domain.subRange(dimensions))
98 check += pt;
99
100 return check;
101 };
102
103 BENCHMARK("Domain reverse traversal using subRange")
104 {
105 Point check;
106 const auto range = domain.subRange(dimensions);
107
108 for (auto it = range.rbegin(), it_end = range.rend(); it != it_end; ++it)
109 check += *it;
110
111 return check;
112 };
113}
114
ConstReverseIterator rbegin() const
ConstSubRange subRange(const std::vector< Dimension > &permutation) const
ConstReverseIterator rend() const
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
Definition: SpaceND.h:110
DGtal::LinearOperator< Calculus, dim, duality, dim, duality > diagonal(const DGtal::KForm< Calculus, dim, duality > &kform)
Definition: DECHelpers.h:60
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
Definition: Common.h:137
STL namespace.
BENCHMARK(BM_StringCreation)
MyPointD Point
Definition: testClone2.cpp:383
TEST_CASE_METHOD(Fixture_object_diamond_with_hole, "Basic Graph functions", "[interface]")
Domain domain