Skip to content

Commit 860813d

Browse files
committed
Benchmarks: Change search benchmarks' metrics
1 parent 0f31ee9 commit 860813d

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

benchmarks/automatic/main.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ namespace
265265
static void Contains(benchmark::State& state)
266266
{
267267
constexpr dim_t DIMENSION_NO = 3;
268-
constexpr depth_t depth = 5;
268+
constexpr depth_t depth = 8;
269269

270270
size_t entityNo = state.range();
271271

@@ -284,14 +284,14 @@ namespace
284284
static void RangeSearch(benchmark::State& state)
285285
{
286286
constexpr dim_t DIMENSION_NO = 3;
287-
constexpr depth_t depth = 5;
287+
constexpr depth_t depth = 8;
288288

289289
size_t entityNo = state.range();
290290

291291
auto const points = GeneratePointsRandom<DIMENSION_NO>(entityNo);
292292
auto const tree = TreePointND<DIMENSION_NO>(points, depth);
293293
constexpr size_t boxNo = 100;
294-
auto const searchBoxes = GenerateBoxesRandom<DIMENSION_NO>(boxNo);
294+
auto const searchBoxes = GenerateBoxesRandom<DIMENSION_NO>(boxNo, 1, 0.05);
295295

296296
size_t entityID = 0;
297297
for (auto _ : state)
@@ -326,7 +326,7 @@ namespace
326326
static void FrustumCulling(benchmark::State& state)
327327
{
328328
constexpr dim_t DIMENSION_NO = 3;
329-
constexpr depth_t depth = 5;
329+
constexpr depth_t depth = 8;
330330

331331
size_t entityNo = state.range();
332332

@@ -458,12 +458,12 @@ namespace
458458
{
459459
constexpr bool DO_SPLIT_PARENT_ENTITIES = SPLIT_DEPTH_INCREASEMENT > 0;
460460
constexpr dim_t DIMENSION_NO = 3;
461-
constexpr depth_t depth = 5;
461+
constexpr depth_t depth = 8;
462462
using EntityID = TreeBoxND<DIMENSION_NO, DO_SPLIT_PARENT_ENTITIES>::TEntityID;
463463

464464
size_t entityNo = state.range();
465465

466-
auto const entities = GenerateBoxesRandom<DIMENSION_NO>(entityNo);
466+
auto const entities = GenerateBoxesRandom<DIMENSION_NO>(entityNo, 0, 0.02);
467467
auto const boxSpace = CreateSearcBox<DIMENSION_NO>(0, rMax);
468468
auto const tree = TreeBoxND<DIMENSION_NO, DO_SPLIT_PARENT_ENTITIES>(entities, depth, boxSpace);
469469

@@ -484,16 +484,16 @@ namespace
484484
{
485485
constexpr bool DO_SPLIT_PARENT_ENTITIES = SPLIT_DEPTH_INCREASEMENT > 0;
486486
constexpr dim_t DIMENSION_NO = 3;
487-
constexpr depth_t depth = 5;
487+
constexpr depth_t depth = 8;
488488

489489
size_t entityNo = state.range();
490490

491-
auto const entities = GenerateBoxesRandom<DIMENSION_NO>(entityNo);
491+
auto const entities = GenerateBoxesRandom<DIMENSION_NO>(entityNo, 0, 0.02);
492492
auto const boxSpace = CreateSearcBox<DIMENSION_NO>(0, rMax);
493493
auto const tree = TreeBoxND<DIMENSION_NO, DO_SPLIT_PARENT_ENTITIES>(entities, depth, boxSpace);
494494

495495
constexpr size_t boxNo = 100;
496-
auto const searchBoxes = GenerateBoxesRandom<DIMENSION_NO>(boxNo, 1);
496+
auto const searchBoxes = GenerateBoxesRandom<DIMENSION_NO>(boxNo, 1, 0.02);
497497

498498
size_t entityID = 0;
499499
for (auto _ : state)
@@ -509,11 +509,11 @@ namespace
509509
{
510510
constexpr bool DO_SPLIT_PARENT_ENTITIES = SPLIT_DEPTH_INCREASEMENT > 0;
511511
constexpr dim_t DIMENSION_NO = 3;
512-
constexpr depth_t depth = 5;
512+
constexpr depth_t depth = 8;
513513

514514
size_t entityNo = state.range();
515515

516-
auto const entities = GenerateBoxesRandom<DIMENSION_NO>(entityNo);
516+
auto const entities = GenerateBoxesRandom<DIMENSION_NO>(entityNo, 0, 0.05);
517517
auto const boxSpace = CreateSearcBox<DIMENSION_NO>(0, rMax);
518518
auto const tree = TreeBoxND<DIMENSION_NO, DO_SPLIT_PARENT_ENTITIES>(entities, depth, boxSpace);
519519

@@ -534,10 +534,10 @@ namespace
534534
{
535535
constexpr bool DO_SPLIT_PARENT_ENTITIES = SPLIT_DEPTH_INCREASEMENT > 0;
536536
constexpr dim_t DIMENSION_NO = 3;
537-
constexpr depth_t depth = 5;
537+
constexpr depth_t depth = 8;
538538

539539
size_t entityNo = state.range();
540-
auto const entities = GenerateBoxesRandom<DIMENSION_NO>(entityNo);
540+
auto const entities = GenerateBoxesRandom<DIMENSION_NO>(entityNo, 0, 0.05);
541541
auto const boxSpace = CreateSearcBox<DIMENSION_NO>(0, rMax);
542542
auto const tree = TreeBoxND<DIMENSION_NO, DO_SPLIT_PARENT_ENTITIES>(entities, depth, boxSpace);
543543

@@ -553,11 +553,11 @@ namespace
553553
{
554554
constexpr bool DO_SPLIT_PARENT_ENTITIES = SPLIT_DEPTH_INCREASEMENT > 0;
555555
constexpr dim_t DIMENSION_NO = 3;
556-
constexpr depth_t depth = 5;
556+
constexpr depth_t depth = 8;
557557

558558
size_t entityNo = state.range();
559-
auto const entities0 = GenerateBoxesRandom<DIMENSION_NO>(entityNo, 0);
560-
auto const entities1 = GenerateBoxesRandom<DIMENSION_NO>(entityNo, 1);
559+
auto const entities0 = GenerateBoxesRandom<DIMENSION_NO>(entityNo, 0, 0.05);
560+
auto const entities1 = GenerateBoxesRandom<DIMENSION_NO>(entityNo, 1, 0.05);
561561
auto const boxSpace = CreateSearcBox<DIMENSION_NO>(0, rMax);
562562
auto const tree0 = TreeBoxND<DIMENSION_NO, DO_SPLIT_PARENT_ENTITIES>(entities0, depth, boxSpace);
563563
auto const tree1 = TreeBoxND<DIMENSION_NO, DO_SPLIT_PARENT_ENTITIES>(entities1, depth, boxSpace);
@@ -599,11 +599,11 @@ namespace
599599
{
600600
constexpr bool DO_SPLIT_PARENT_ENTITIES = SPLIT_DEPTH_INCREASEMENT > 0;
601601
constexpr dim_t DIMENSION_NO = 3;
602-
constexpr depth_t depth = 5;
602+
constexpr depth_t depth = 8;
603603

604604
size_t entityNo = state.range();
605605

606-
auto const entities = GenerateBoxesRandom<DIMENSION_NO>(entityNo, 2);
606+
auto const entities = GenerateBoxesRandom<DIMENSION_NO>(entityNo, 2, 0.02);
607607
auto const boxSpace = CreateSearcBox<DIMENSION_NO>(0, rMax);
608608
auto const tree = TreeBoxND<DIMENSION_NO, DO_SPLIT_PARENT_ENTITIES>(entities, depth, boxSpace);
609609

@@ -628,11 +628,11 @@ namespace
628628
auto const& ray = rays[entityID % rays.size()];
629629
if constexpr (IS_FIRST)
630630
{
631-
tree.RayIntersectedFirst(ray.Origin, ray.Direction, entities, 0);
631+
benchmark::DoNotOptimize(tree.RayIntersectedFirst(ray.Origin, ray.Direction, entities, 0));
632632
}
633633
else
634634
{
635-
tree.RayIntersectedAll(ray.Origin, ray.Direction, entities, 0);
635+
benchmark::DoNotOptimize(tree.RayIntersectedAll(ray.Origin, ray.Direction, entities, 0));
636636
}
637637
++entityID;
638638
}

benchmarks/manual/generators.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,12 @@ constexpr std::vector<BoundingBoxND<DIMENSION_NO>> GenerateBoxesRandom(size_t nN
121121

122122
{
123123
auto const rMaxBoxSize = boxSizeScale * rMax;
124-
for (size_t iRemain = 1; iNumber < nNumber; ++iNumber, ++iRemain)
124+
for (; iNumber < nNumber; ++iNumber)
125125
{
126-
auto const iNumberBox = nNumber - iNumber - 1;
127126
for (dim_t iDim = 0; iDim < DIMENSION_NO && iNumber < nNumber; ++iDim)
128127
{
129-
aBox[iNumberBox].Min[iDim] = double(rng() % 100) * ((rMax - 1.0) / 100.0);
130-
aBox[iNumberBox].Max[iDim] = std::min(rMax, aBox[iNumberBox].Min[iDim] + (double(rng() % 100) / 100.0) * rMaxBoxSize);
128+
aBox[iNumber].Min[iDim] = double(rng() % 100) * ((rMax - 1.0) / 100.0);
129+
aBox[iNumber].Max[iDim] = std::min(rMax, aBox[iNumber].Min[iDim] + (double(rng() % 100) / 100.0) * rMaxBoxSize);
131130
}
132131
}
133132
}

0 commit comments

Comments
 (0)