DGtal 1.4.0
Loading...
Searching...
No Matches
benchmarkImageContainer.cpp File Reference
#include <iostream>
#include <benchmark/benchmark.h>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/helpers/StdDefs.h"
#include <map>
#include <string>
Include dependency graph for benchmarkImageContainer.cpp:

Go to the source code of this file.

Typedefs

typedef DGtal::ImageContainerBySTLVector< Z2i::Domain, DGtal::int32_tImageVector2
 
typedef DGtal::ImageContainerBySTLMap< Z2i::Domain, DGtal::int32_tImageMap2
 
typedef DGtal::experimental::ImageContainerByHashTree< Z2i::Domain, DGtal::int32_tImageHash2
 

Functions

template<typename Q >
static void BM_Constructor (benchmark::State &state)
 
 BENCHMARK_TEMPLATE (BM_Constructor, ImageVector2) -> Range(1<< 3, 1<< 10)
 
 BENCHMARK_TEMPLATE (BM_Constructor, ImageMap2) -> Range(1<< 3, 1<< 16)
 
 BENCHMARK_TEMPLATE (BM_Constructor, ImageHash2) -> Range(1<< 3, 1<< 16)
 
template<typename Point >
std::set< PointConstructRandomSet (unsigned int size, unsigned int maxWidth)
 
template<typename Q >
static void BM_SetValue (benchmark::State &state)
 
 BENCHMARK_TEMPLATE (BM_SetValue, ImageVector2) -> Range(1<< 3, 1<< 10)
 
 BENCHMARK_TEMPLATE (BM_SetValue, ImageMap2) -> Range(1<< 3, 1<< 16)
 
 BENCHMARK_TEMPLATE (BM_SetValue, ImageHash2) -> Range(1<< 3, 1<< 10)
 
template<typename Q >
static void BM_RangeScan (benchmark::State &state)
 
 BENCHMARK_TEMPLATE (BM_RangeScan, ImageVector2) -> Range(1<< 3, 1<< 10)
 
 BENCHMARK_TEMPLATE (BM_RangeScan, ImageMap2) -> Range(1<< 3, 1<< 10)
 
template<typename Q >
static void BM_DomainScan (benchmark::State &state)
 
 BENCHMARK_TEMPLATE (BM_DomainScan, ImageVector2) -> Range(1<< 3, 1<< 10)
 
 BENCHMARK_TEMPLATE (BM_DomainScan, ImageMap2) -> Range(1<< 3, 1<< 10)
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2010/07/22

Functions for testing class ImageContainerBenchmark.

This file is part of the DGtal library.

Definition in file benchmarkImageContainer.cpp.

Typedef Documentation

◆ ImageHash2

◆ ImageMap2

◆ ImageVector2

Function Documentation

◆ BENCHMARK_TEMPLATE() [1/10]

BENCHMARK_TEMPLATE ( BM_Constructor ,
ImageHash2  ) -> Range(1<< 3, 1<< 16)

◆ BENCHMARK_TEMPLATE() [2/10]

BENCHMARK_TEMPLATE ( BM_Constructor ,
ImageMap2  ) -> Range(1<< 3, 1<< 16)

◆ BENCHMARK_TEMPLATE() [3/10]

BENCHMARK_TEMPLATE ( BM_Constructor ,
ImageVector2  ) -> Range(1<< 3, 1<< 10)

◆ BENCHMARK_TEMPLATE() [4/10]

BENCHMARK_TEMPLATE ( BM_DomainScan ,
ImageMap2  ) -> Range(1<< 3, 1<< 10)

◆ BENCHMARK_TEMPLATE() [5/10]

BENCHMARK_TEMPLATE ( BM_DomainScan ,
ImageVector2  ) -> Range(1<< 3, 1<< 10)

◆ BENCHMARK_TEMPLATE() [6/10]

BENCHMARK_TEMPLATE ( BM_RangeScan ,
ImageMap2  ) -> Range(1<< 3, 1<< 10)

◆ BENCHMARK_TEMPLATE() [7/10]

BENCHMARK_TEMPLATE ( BM_RangeScan ,
ImageVector2  ) -> Range(1<< 3, 1<< 10)

◆ BENCHMARK_TEMPLATE() [8/10]

BENCHMARK_TEMPLATE ( BM_SetValue ,
ImageHash2  ) -> Range(1<< 3, 1<< 10)

◆ BENCHMARK_TEMPLATE() [9/10]

BENCHMARK_TEMPLATE ( BM_SetValue ,
ImageMap2  ) -> Range(1<< 3, 1<< 16)

◆ BENCHMARK_TEMPLATE() [10/10]

BENCHMARK_TEMPLATE ( BM_SetValue ,
ImageVector2  ) -> Range(1<< 3, 1<< 10)

◆ BM_Constructor()

template<typename Q >
static void BM_Constructor ( benchmark::State & state)
static

Definition at line 55 of file benchmarkImageContainer.cpp.

56{
57 while (state.KeepRunning())
58 {
59 state.PauseTiming();
60 typename Q::Domain dom(typename Q::Point().diagonal(0),
61 typename Q::Point().diagonal(state.range(0)));
62 state.ResumeTiming();
63 Q image( dom );
64 }
65}
DGtal::LinearOperator< Calculus, dim, duality, dim, duality > diagonal(const DGtal::KForm< Calculus, dim, duality > &kform)
Definition DECHelpers.h:60

◆ BM_DomainScan()

template<typename Q >
static void BM_DomainScan ( benchmark::State & state)
static

Definition at line 140 of file benchmarkImageContainer.cpp.

141{
142 std::set<typename Q::Point> data = ConstructRandomSet<typename Q::Point>(state.range(0),state.range(0));
143 int sum=0;
144 while (state.KeepRunning())
145 {
146 state.PauseTiming();
147 typename Q::Domain dom(typename Q::Point().diagonal(0),
148 typename Q::Point().diagonal(state.range(0)));
149 Q image( dom );
150 for(typename std::set<typename Q::Point>::const_iterator it = data.begin(), itend=data.end();
151 it != itend; ++it)
152 image.setValue( *it , 42);
153 state.ResumeTiming();
154 for(typename Q::Domain::ConstIterator it = image.domain().begin(), itend=image.domain().end();
155 it != itend; ++it)
156 benchmark::DoNotOptimize( sum ++ );
157 }
158 std::stringstream ss;
159 ss << sum;
160 state.SetLabel(ss.str());
161}
std::set< Point > ConstructRandomSet(unsigned int size, unsigned int maxWidth)

References ConstructRandomSet().

◆ BM_RangeScan()

template<typename Q >
static void BM_RangeScan ( benchmark::State & state)
static

Definition at line 114 of file benchmarkImageContainer.cpp.

115{
116 std::set<typename Q::Point> data = ConstructRandomSet<typename Q::Point>(state.range(0),state.range(0));
117 int sum=0;
118 while (state.KeepRunning())
119 {
120 state.PauseTiming();
121 typename Q::Domain dom(typename Q::Point().diagonal(0),
122 typename Q::Point().diagonal(state.range(0)));
123 Q image( dom );
124 for(typename std::set<typename Q::Point>::const_iterator it = data.begin(), itend=data.end();
125 it != itend; ++it)
126 image.setValue( *it , 42);
127 state.ResumeTiming();
128 for(typename Q::Range::ConstIterator it = image.range().begin(), itend=image.range().end();
129 it != itend; ++it)
130 benchmark::DoNotOptimize(sum += *it); //to prevent compiler optimization
131 }
132 std::stringstream ss;
133 ss << sum;
134 state.SetLabel(ss.str());
135}

References ConstructRandomSet().

◆ BM_SetValue()

template<typename Q >
static void BM_SetValue ( benchmark::State & state)
static

Definition at line 85 of file benchmarkImageContainer.cpp.

86{
87 std::set<typename Q::Point> data = ConstructRandomSet<typename Q::Point>(state.range(0),state.range(0));
88
89 int64_t cpt=0;
90 while (state.KeepRunning())
91 {
92 state.PauseTiming();
93 typename Q::Domain dom(typename Q::Point().diagonal(0),
94 typename Q::Point().diagonal(state.range(0)));
95 Q image( dom );
96 for(typename std::set<typename Q::Point>::const_iterator it = data.begin(), itend=data.end();
97 it != itend; ++it)
98 {
99 state.ResumeTiming();
100 image.setValue( *it , 42);
101 state.PauseTiming();
102 cpt++;
103 }
104 }
105 // const int64_t items_processed =
106 // static_cast<int64_t>(state.iterations())*state.range(0);
107 state.SetItemsProcessed(cpt);
108}
boost::int64_t int64_t
signed 94-bit integer.
Definition BasicTypes.h:74

References ConstructRandomSet().

◆ ConstructRandomSet()

template<typename Point >
std::set< Point > ConstructRandomSet ( unsigned int size,
unsigned int maxWidth )

Definition at line 71 of file benchmarkImageContainer.cpp.

71 {
72 std::set<Point> s;
73 Point p;
74 for (unsigned int i = 0; i < size; ++i)
75 {
76 for(unsigned int j=0; j < Point::dimension; j++)
77 p[j] = rand() % maxWidth;
78 s.insert( p );
79 }
80 return s;
81}
MyPointD Point

Referenced by BM_DomainScan(), BM_RangeScan(), and BM_SetValue().

◆ main()

int main ( int argc,
char ** argv )

Definition at line 171 of file benchmarkImageContainer.cpp.

172{
173 benchmark::Initialize(&argc, argv);
174
175 benchmark::RunSpecifiedBenchmarks();
176 return 0;
177}