From 06d259dd5c5dc2990e81026861a04aef63dcccca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 22 Mar 2026 23:39:16 +0100 Subject: [PATCH] Put early algorithm termination positions in the middle of the sequence to have a better representation of the average performance of the algorithms --- experimental/bench_segmented_algos.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/experimental/bench_segmented_algos.cpp b/experimental/bench_segmented_algos.cpp index 12e7777..534373f 100644 --- a/experimental/bench_segmented_algos.cpp +++ b/experimental/bench_segmented_algos.cpp @@ -504,6 +504,9 @@ FwdIt find_last_if_not(FwdIt first, FwdIt last, Pred pred) //is_heap (random-access non-implementable?) //is_heap_until (random-access non-implementable?) +//not implemented (c++14) +//mismatch with two full ranges +//equal with two full ranges //not implemented (c++17) //for_each_n @@ -1954,9 +1957,7 @@ void run_all(const C& c, std::size_t iters, const char* cname) { C c2(c); bench_equal(c, c2, iters, cname, "equal(hit)"); - typename C::iterator last = c2.end(); - --last; - *last = VT(-1); + c2[c2.size() / 2u] = VT(-1); bench_equal(c, c2, iters, cname, "equal(miss)"); } @@ -2003,9 +2004,7 @@ void run_all(const C& c, std::size_t iters, const char* cname) { bench_is_partitioned(c, iters, cname, is_negative(), "is_partitioned(hit)"); C c2(c); - typename C::iterator last = c2.end(); - --last; - *last = VT(-1); + c2[c2.size() / 2u] = VT(-1); bench_is_partitioned(c2, iters, cname, is_negative(), "is_partitioned(miss)"); } @@ -2013,9 +2012,7 @@ void run_all(const C& c, std::size_t iters, const char* cname) { bench_is_sorted(c, iters, cname, "is_sorted(hit)"); C c2(c); - typename C::iterator last = c2.end(); - --last; - *last = VT(0); + c2[c2.size() / 2u] = VT(-1); bench_is_sorted(c2, iters, cname, "is_sorted(miss)"); } @@ -2023,9 +2020,7 @@ void run_all(const C& c, std::size_t iters, const char* cname) { bench_is_sorted_until(c, iters, cname, "is_sorted_until(hit)"); C c2(c); - typename C::iterator last = c2.end(); - --last; - *last = VT(0); + c2[c2.size() / 2u] = VT(-1); bench_is_sorted_until(c2, iters, cname, "is_sorted_until(miss)"); } @@ -2040,8 +2035,9 @@ void run_all(const C& c, std::size_t iters, const char* cname) //mismatch { C c2(c); - bench_mismatch(c, c2, iters, cname, "mismatch(hit)"); c2[c2.size()/2] = VT(-1); + bench_mismatch(c, c2, iters, cname, "mismatch(hit)"); + c2[c2.size()/2] = c[c2.size()/2]; bench_mismatch(c, c2, iters, cname, "mismatch(miss)"); } @@ -2134,7 +2130,7 @@ void run_benchmarks() { #ifdef NDEBUG const std::size_t N = 10000; - const std::size_t iter = 500; + const std::size_t iter = 1000; #else const std::size_t N = 10000; const std::size_t iter = 1;