From b4d95c3842577e0fcb71e2d3e4adda7c82a661ba Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 14 Feb 2026 20:13:10 +0000 Subject: 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. --- test/perf-instancing.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'test/perf-instancing.cpp') 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(state.range())); @@ -39,8 +39,28 @@ namespace { pos %= 1000000; } } + + void + partition2(benchmark::State & state) + { + TestMainWindowAppBase window; + Data data(static_cast(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(); -- cgit v1.3