diff --git a/libcxx/docs/Status/Cxx20Issues.csv b/libcxx/docs/Status/Cxx20Issues.csv --- a/libcxx/docs/Status/Cxx20Issues.csv +++ b/libcxx/docs/Status/Cxx20Issues.csv @@ -1,6 +1,6 @@ "Issue #","Issue Name","Meeting","Status","First released version","Labels" "`2070 `__","``allocate_shared``\ should use ``allocator_traits::construct``\ ","Toronto","Resolved by `P0674R1 `__","" -"`2444 `__","Inconsistent complexity for ``std::sort_heap``\ ","Toronto","","" +"`2444 `__","Inconsistent complexity for ``std::sort_heap``\ ","Toronto","|Nothing To Do|","" "`2593 `__","Moved-from state of Allocators","Toronto","","" "`2597 `__","``std::log``\ misspecified for complex numbers","Toronto","","" "`2783 `__","``stack::emplace()``\ and ``queue::emplace()``\ should return ``decltype(auto)``\ ","Toronto","|Complete|","" diff --git a/libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp b/libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp --- a/libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp +++ b/libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include "test_macros.h" @@ -48,28 +49,31 @@ int main(int, char**) { - const int N = 100'000; + constexpr int N = (1 << 20); std::vector v; v.reserve(N); std::mt19937 g; - for (int i = 0; i < N; ++i) - v.emplace_back(g()); - std::make_heap(v.begin(), v.end()); - - // The exact stats of our current implementation are recorded here. - // If something changes to make them go a bit up or down, that's probably fine, - // and we can just update this test. - // But if they suddenly leap upward, that's a bad thing. - - stats = {}; - std::sort_heap(v.begin(), v.end()); - assert(stats.copied == 0); - assert(stats.moved == 1'764'997); + for (int i = 0; i < N; ++i) { + v.emplace_back(i); + } + for (int logn = 10; logn <= 20; ++logn) { + const int n = (1 << logn); + auto first = v.begin(); + auto last = v.begin() + n; + std::shuffle(first, last, g); + std::make_heap(first, last); + // The exact stats of our current implementation are recorded here. + // If something changes to make them go a bit up or down, that's probably + // fine, and we can just update this test. + // But if they suddenly leap upward, that's a bad thing. + stats = {}; + std::sort_heap(first, last); + assert(stats.copied == 0); + assert(stats.moved <= 2 * n + n * logn); #ifndef _LIBCPP_ENABLE_DEBUG_MODE - assert(stats.compared == 1'534'701); + assert(stats.compared <= n * logn); #endif - - assert(std::is_sorted(v.begin(), v.end())); - + assert(std::is_sorted(first, last)); + } return 0; }