245#define BENCH_LINEARIZER( N , ORDER ) \
246TEST_CASE( "Benchmarking Linearizer in dimension " #N " with " #ORDER, "[.bench][dim" #N "][" #ORDER "]" )\
247{\
248\
249 typedef SpaceND<N> Space;\
250 typedef HyperRectDomain<Space> Domain;\
251 typedef Space::Point Point;\
252\
253 typedef linearizer<Domain, N> RefLinearizer;\
254 typedef Linearizer<Domain, ORDER> NewLinearizer;\
255\
256 typedef PointConverter<ORDER> RefConverter;\
257\
258 std::size_t size = 1e8;\
259\
260 Point lowerBound;\
261 for ( std::size_t i = 0 ; i < N ; ++i )\
262 lowerBound[i] = 1 + 7*i;\
263\
264 std::size_t dim_size = std::size_t( std::pow( double(size), 1./N ) + 0.5 );\
265 Point upperBound;\
266 for ( std::size_t i = 0; i < N ; ++i )\
267 upperBound[i] = lowerBound[i] + dim_size + i;\
268\
269 Domain domain( lowerBound, upperBound );\
270 Point extent = upperBound - lowerBound + Point::diagonal(1);\
271\
272 Point refLowerBound = RefConverter::apply(lowerBound);\
273 Point refExtent = RefConverter::apply(extent);\
274\
275 std::size_t sum = 0;\
276\
277 for ( Domain::ConstIterator it = domain.begin(), it_end = domain.end(); it != it_end ; ++it )\
278 sum += RefLinearizer::apply( RefConverter::apply(*it), refLowerBound, refExtent );\
279 REQUIRE( sum > 0 );\
280 sum = 0;\
281\
282 SECTION( "Benchmarking reference linearizer" )\
283 {\
284 for ( Domain::ConstIterator it = domain.begin(), it_end = domain.end(); it != it_end ; ++it )\
285 sum += RefLinearizer::apply( RefConverter::apply(*it), refLowerBound, refExtent );\
286 }\
287\
288 SECTION( "Benchmarking getIndex(Point, Point, Extent) syntax" )\
289 {\
290 for ( Domain::ConstIterator it = domain.begin(), it_end = domain.end(); it != it_end ; ++it )\
291 sum += NewLinearizer::getIndex( *it, lowerBound, extent );\
292 }\
293\
294 SECTION( "Benchmarking getIndex(Point, Extent) syntax" )\
295 {\
296 for ( Domain::ConstIterator it = domain.begin(), it_end = domain.end(); it != it_end ; ++it )\
297 sum += NewLinearizer::getIndex( *it, extent );\
298 }\
299\
300 SECTION( "Benchmarking getIndex(Point, Domain) syntax" )\
301 {\
302 for ( Domain::ConstIterator it = domain.begin(), it_end = domain.end(); it != it_end ; ++it )\
303 sum += NewLinearizer::getIndex( *it, domain );\
304 }\
305\
306 SECTION( "Benchmarking getPoint(Index, Point, Extent) syntax" )\
307 {\
308 for ( std::size_t i = 0; i < domain.size(); ++i )\
309 sum += NewLinearizer::getPoint( i, lowerBound, extent )[N-1];\
310 }\
311\
312 SECTION( "Benchmarking getPoint(Index, Extent) syntax" )\
313 {\
314 for ( std::size_t i = 0; i < domain.size(); ++i )\
315 sum += NewLinearizer::getPoint( i, extent )[N-1];\
316 }\
317\
318 SECTION( "Benchmarking getPoint(Index, Domain) syntax" )\
319 {\
320 for ( std::size_t i = 0; i < domain.size(); ++i )\
321 sum += NewLinearizer::getPoint( i, domain )[N-1];\
322 }\
323\
324 REQUIRE( sum > 0 );\
325}