Skip to content

Commit b367d96

Browse files
committed
Benchmarks for RangeSearch
1 parent 530c0f8 commit b367d96

File tree

1 file changed

+50
-30
lines changed

1 file changed

+50
-30
lines changed

benchmarks/benchmarks.cpp

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ namespace
108108
std::mt19937 g(rd());
109109
g.seed();
110110
std::shuffle(next(begin(aPoint), nNumberPre), end(aPoint), g);
111-
112-
[[maybe_unused]] autoc box = Adaptor::GetBoxOfPoints(aPoint);
113-
assert(Adaptor::ArePointsEqual(box.Max, ptMax, 0.0001));
114-
assert(Adaptor::ArePointsEqual(box.Min, PointND<nDim>{}, 0.0001));
115-
116111
return aPoint;
117112
}
118113

@@ -147,10 +142,6 @@ namespace
147142

148143
}
149144

150-
[[maybe_unused]] autoc box = Adaptor::GetBoxOfPoints(aPoint);
151-
assert(Adaptor::ArePointsEqual(box.Max, ptMax, 0.0001));
152-
assert(Adaptor::ArePointsEqual(box.Min, PointND<nDim>{}, 0.0001));
153-
154145
return aPoint;
155146
}
156147

@@ -190,10 +181,6 @@ namespace
190181
}
191182
}
192183

193-
[[maybe_unused]] autoc box = Adaptor::GetBoxOfPoints(aPoint);
194-
assert(Adaptor::ArePointsEqual(box.Max, ptMax, 0.0001));
195-
assert(Adaptor::ArePointsEqual(box.Min, PointND<nDim>{}, 0.0001));
196-
197184
return aPoint;
198185
}
199186

@@ -591,7 +578,7 @@ namespace
591578

592579

593580
template<dim_t N>
594-
vector<MeasurementTask<BoundingBoxND<N>>> SearchTreeBoxTasks(depth_t nDepth, string const& szName, span<BoundingBoxND<N> const> const& aBox_)
581+
vector<MeasurementTask<BoundingBoxND<N>>> CollisionDetectionBoxTasks(depth_t nDepth, string const& szName, span<BoundingBoxND<N> const> const& aBox_)
595582
{
596583
auto vTask = vector<MeasurementTask<BoundingBoxND<N>>>();
597584
for (autoc fPar : { false, true })
@@ -619,33 +606,64 @@ namespace
619606
{
620607
TreeBoxND<N, nSplit>::template Create<std::execution::parallel_unsequenced_policy>(nt, aBox, nDepth, boxMax);
621608
autoc vPair = nt.template CollisionDetection<std::execution::parallel_unsequenced_policy>(aBox);
622-
return size_t{};
623-
//return nt.GetNodes().size();
609+
return nt.GetNodes().size();
624610
}
625611
else
626612
{
627613
TreeBoxND<N, nSplit>::Create(nt, aBox, nDepth, boxMax);
628614
autoc vPair = nt.CollisionDetection(aBox);
629615
return vPair.size();
630-
//return nt.GetNodes().size();
631-
/*
632-
size_t nFound = 0;
633-
autoc n = aBox.size();
634-
for (size_t i = 0; i < n; ++i)
635-
{
636-
autoc vElem = nt.RangeSearch<false>(aBox[i], aBox);
637-
nFound += vElem.size();
638-
assert(vElem.size());
639-
}
640-
return nFound;
641-
*/
642616
}
643617
}
644618
});
645619
}
646620
return vTask;
647621
}
648622

623+
template<dim_t N>
624+
vector<MeasurementTask<BoundingBoxND<N>>> SearchTreeBoxTasks(depth_t nDepth, string const& szName, span<BoundingBoxND<N> const> const& aBox_)
625+
{
626+
auto vTask = vector<MeasurementTask<BoundingBoxND<N>>>();
627+
for (size_t iSize = 0; iSize < nSizeNonLog; ++iSize)
628+
{
629+
auto nDepthActual = nDepth;
630+
if (nDepth == -1) // Adapt to the size
631+
{
632+
if (aSizeNonLog[iSize] <= 100)
633+
nDepthActual = 3;
634+
else if (aSizeNonLog[iSize] <= 500)
635+
nDepthActual = 3;
636+
else if (aSizeNonLog[iSize] <= 1000)
637+
nDepthActual = 4;
638+
else if (aSizeNonLog[iSize] <= 10000)
639+
nDepthActual = 5;
640+
else
641+
nDepthActual = 6;
642+
}
643+
vTask.push_back(MeasurementTask<BoundingBoxND<N>>{ szName,
644+
aSizeNonLog[iSize],
645+
aRepeatNonLog[iSize],
646+
nDepthActual,
647+
false,
648+
aBox_.subspan(0, aSizeNonLog[iSize]),
649+
[](depth_t nDepth, span<BoundingBoxND<N> const> const& aBox, bool fPar) {
650+
autoce nSplit = 2;
651+
auto nt = TreeBoxND<N, nSplit>{};
652+
TreeBoxND<N, nSplit>::Create(nt, aBox, nDepth, boxMax);
653+
size_t nFound = 0;
654+
autoc n = aBox.size();
655+
for (size_t i = 0; i < n; ++i)
656+
{
657+
autoc vElem = nt.template RangeSearch<false>(aBox[i], aBox);
658+
nFound += vElem.size();
659+
assert(vElem.size());
660+
}
661+
return nFound;
662+
} });
663+
}
664+
return vTask;
665+
}
666+
649667
template<dim_t N>
650668
vector<MeasurementTask<BoundingBoxND<N>>> SearchBruteForceBoxTasks(depth_t nDepth, string const& szName, span<BoundingBoxND<N> const> const& aBox_)
651669
{
@@ -821,10 +839,12 @@ int main()
821839
autoc szName = string("Search: Cylindrical semi-random placed point NoPt/NoBox:100%");
822840
autoc aBox = GenerateGeometry<N, vector<BoundingBoxND<N>>>([&] { return CreateBoxes_CylindricalSemiRandom<N, static_cast<size_t>(aSizeNonLog.back())>(); }, szName, aSizeNonLog.back(), report);
823841
autoc vTaskBruteForce = SelfConflictBruteForceBoxTasks<N>("Box self conflict by brute force", aBox);
824-
autoc vTaskTree = SearchTreeBoxTasks<N>(3, "Box self conflict by octree", aBox);
842+
autoc vTaskTreeCollisionDetection = CollisionDetectionBoxTasks<N>(3, "Box self conflict by octree", aBox);
843+
autoc vTaskTreeSearch = SearchTreeBoxTasks<N>(3, "Box search by octree", aBox);
825844

826845
RunTasks(vTaskBruteForce, report);
827-
RunTasks(vTaskTree, report);
846+
RunTasks(vTaskTreeCollisionDetection, report);
847+
RunTasks(vTaskTreeSearch, report);
828848
}
829849

830850
report.close();

0 commit comments

Comments
 (0)