32#include <benchmark/benchmark.h>
33#include "DGtal/base/Common.h"
35#include "DGtal/base/Common.h"
36#include "DGtal/kernel/SpaceND.h"
37#include "DGtal/kernel/domains/HyperRectDomain.h"
38#include "DGtal/images/ImageSelector.h"
40#include "DGtal/helpers/StdDefs.h"
57 while (state.KeepRunning())
60 typename Q::Domain dom(
typename Q::Point().diagonal(0),
61 typename Q::Point().diagonal(state.range(0)));
70template<
typename Po
int>
74 for (
unsigned int i = 0; i < size; ++i)
76 for(
unsigned int j=0; j < Point::dimension; j++)
77 p[j] = rand() % maxWidth;
87 std::set<typename Q::Point> data = ConstructRandomSet<typename Q::Point>(state.range(0),state.range(0));
90 while (state.KeepRunning())
93 typename Q::Domain dom(
typename Q::Point().diagonal(0),
94 typename Q::Point().diagonal(state.range(0)));
96 for(
typename std::set<typename Q::Point>::const_iterator it = data.begin(), itend=data.end();
100 image.setValue( *it , 42);
107 state.SetItemsProcessed(cpt);
116 std::set<typename Q::Point> data = ConstructRandomSet<typename Q::Point>(state.range(0),state.range(0));
118 while (state.KeepRunning())
121 typename Q::Domain dom(
typename Q::Point().diagonal(0),
122 typename Q::Point().diagonal(state.range(0)));
124 for(
typename std::set<typename Q::Point>::const_iterator it = data.begin(), itend=data.end();
126 image.setValue( *it , 42);
127 state.ResumeTiming();
128 for(
typename Q::Range::ConstIterator it = image.range().begin(), itend=image.range().end();
130 benchmark::DoNotOptimize(sum += *it);
132 std::stringstream ss;
134 state.SetLabel(ss.str());
142 std::set<typename Q::Point> data = ConstructRandomSet<typename Q::Point>(state.range(0),state.range(0));
144 while (state.KeepRunning())
147 typename Q::Domain dom(
typename Q::Point().diagonal(0),
148 typename Q::Point().diagonal(state.range(0)));
150 for(
typename std::set<typename Q::Point>::const_iterator it = data.begin(), itend=data.end();
152 image.setValue( *it , 42);
153 state.ResumeTiming();
154 for(
typename Q::Domain::ConstIterator it = image.domain().begin(), itend=image.domain().end();
156 benchmark::DoNotOptimize( sum ++ );
158 std::stringstream ss;
160 state.SetLabel(ss.str());
171int main(
int argc,
char **argv )
173 benchmark::Initialize(&argc, argv);
175 benchmark::RunSpecifiedBenchmarks();
static void BM_SetValue(benchmark::State &state)
std::set< Point > ConstructRandomSet(unsigned int size, unsigned int maxWidth)
static void BM_Constructor(benchmark::State &state)
BENCHMARK_TEMPLATE(BM_Constructor, ImageVector2) -> Range(1<< 3, 1<< 10)
DGtal::ImageContainerBySTLVector< Z2i::Domain, DGtal::int32_t > ImageVector2
DGtal::experimental::ImageContainerByHashTree< Z2i::Domain, DGtal::int32_t > ImageHash2
DGtal::ImageContainerBySTLMap< Z2i::Domain, DGtal::int32_t > ImageMap2
static void BM_RangeScan(benchmark::State &state)
static void BM_DomainScan(benchmark::State &state)
Model of CImageContainer implementing the association key<->Value using a hash tree....
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::int64_t int64_t
signed 94-bit integer.