[libcxx-commits] [PATCH] D118003: [libc++] Floyd's improvement to pop_heap

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 7 14:04:38 PST 2022


Quuxplusone updated this revision to Diff 413629.
Quuxplusone added a comment.
Herald added a subscriber: mgrang.

Add complexity.pass.cpp for sort_heap and also for make_heap, since I've got those numbers already.
I thought of trying to make the assertions "fuzzy," but couldn't see a mathematically justifiable way of doing that, and besides, these numbers should never change unless they're deliberately //being// changed by someone who cares about these numbers! (As in this PR.)

Will land the tests first, with the old numbers, so that the main commit can braggingly update the numbers in place:

  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
  index 28f82d61da33..8c10f81d767e 100644
  --- 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
  @@ -65,8 +65,8 @@ int main(int, char**)
     stats = {};
     std::sort_heap(v.begin(), v.end());
     assert(stats.copied == 0);
  -  assert(stats.moved == 1'900'731);
  -  assert(stats.compared == 2'831'757);
  +  assert(stats.moved == 1'764'997);
  +  assert(stats.compared == 1'534'701);
   
     assert(std::is_sorted(v.begin(), v.end()));

Re-poking CI, though, to make sure all platforms agree about these numbers. (They're deterministic AFAIK, but I could be wrong.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118003/new/

https://reviews.llvm.org/D118003

Files:
  libcxx/include/__algorithm/pop_heap.h
  libcxx/include/__algorithm/sift_down.h
  libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/make.heap/complexity.pass.cpp
  libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118003.413629.patch
Type: text/x-patch
Size: 7684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220307/df56efbf/attachment.bin>


More information about the libcxx-commits mailing list