summaryrefslogtreecommitdiff
path: root/test/perf-instancing.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2026-02-14 20:13:10 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2026-02-14 20:13:10 +0000
commitb4d95c3842577e0fcb71e2d3e4adda7c82a661ba (patch)
treeb1205ce06f659751f50e8a6e52adea399b593bfb /test/perf-instancing.cpp
parentReturn indices instead of iterates from InstanceVertices::partition (diff)
downloadilt-b4d95c3842577e0fcb71e2d3e4adda7c82a661ba.tar.bz2
ilt-b4d95c3842577e0fcb71e2d3e4adda7c82a661ba.tar.xz
ilt-b4d95c3842577e0fcb71e2d3e4adda7c82a661ba.zip
Add support for partitioning by 2 unary predicates
Second predicate creates a single block of truthy values in the middle, and two falsy blocks at each end.
Diffstat (limited to 'test/perf-instancing.cpp')
-rw-r--r--test/perf-instancing.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/test/perf-instancing.cpp b/test/perf-instancing.cpp
index a56d60e..f3d16a8 100644
--- a/test/perf-instancing.cpp
+++ b/test/perf-instancing.cpp
@@ -26,7 +26,7 @@ namespace {
};
void
- partition(benchmark::State & state)
+ partition1(benchmark::State & state)
{
TestMainWindowAppBase window;
Data data(static_cast<size_t>(state.range()));
@@ -39,8 +39,28 @@ namespace {
pos %= 1000000;
}
}
+
+ void
+ partition2(benchmark::State & state)
+ {
+ TestMainWindowAppBase window;
+ Data data(static_cast<size_t>(state.range()));
+ GlobalPosition2D pos {};
+ for (auto loop : state) {
+ data.instances.partition(
+ [&pos](const auto & instance) {
+ return std::abs(instance.pos.x - pos.x) < 5;
+ },
+ [&pos](const auto & instance) {
+ return std::abs(instance.pos.y - pos.y) < 5;
+ });
+ pos += GlobalPosition2D {33, 17};
+ pos %= 1000000;
+ }
+ }
}
-BENCHMARK(partition)->Range(0, 1 << 20);
+BENCHMARK(partition1)->Range(0, 1 << 20);
+BENCHMARK(partition2)->Range(0, 1 << 20);
BENCHMARK_MAIN();