[libcxx-commits] [PATCH] D61878: Change how containers are compared

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 10 20:47:19 PDT 2019


zoecarver marked an inline comment as done.
zoecarver added a comment.

Also, here are some more benchmarks because I technically changed the comparison function (and also, why not?):

  -------------------------------------------------------------------------------------
  Benchmark                                          Time             CPU   Iterations
  -------------------------------------------------------------------------------------
  initialize_data                                0.000 ns        0.000 ns            0
  test_old/OLD_compare_small_set                 72746 ns        72391 ns        10212
  test_new/NEW_compare_small_set                 27201 ns        27132 ns        24270
  test_old/OLD_compare_similar_set              100853 ns       100354 ns         7101
  test_new/NEW_compare_similar_set               22151 ns        22101 ns        28880
  test_old/OLD_compare_big_set                85456872 ns     85059167 ns            6
  test_new/NEW_compare_big_set                78148398 ns     78032222 ns            9
  test_old/OLD_compare_big_set_different      80389034 ns     80301000 ns            9
  test_new/NEW_compare_big_set_different      76252136 ns     76169200 ns           10
  test_old/OLD_compare_oposite_order_set     338906270 ns    338359500 ns            2
  test_new/NEW_compare_oposite_order_set     308761215 ns    308473500 ns            2
  test_old/OLD_compare_random_set             11021038 ns     11011500 ns           56
  test_new/NEW_compare_random_set              3717716 ns      3710818 ns          192
  test_old/OLD_compare_random_set_different       2720 ns         2718 ns       261663
  test_new/NEW_compare_random_set_different       2674 ns         2671 ns       260192
  test_old/OLD_compare_short_string            2381223 ns      2377644 ns          295
  test_new/NEW_compare_short_string             680146 ns       679617 ns          991
  test_old/OLD_compare_long_string            19782950 ns     19765727 ns           33
  test_new/NEW_compare_long_string             2370050 ns      2367704 ns          301
  test_old/OLD_compare_different_strings          2068 ns         2064 ns       343178
  test_new/NEW_compare_different_strings          2046 ns         2043 ns       346945

and (to be fair to the times this function was slower):

  -------------------------------------------------------------------------------------
  Benchmark                                          Time             CPU   Iterations
  -------------------------------------------------------------------------------------
  initialize_data                                0.000 ns        0.000 ns            0
  test_old/OLD_compare_small_set                 72221 ns        71934 ns         8892
  test_new/NEW_compare_small_set                 30014 ns        29660 ns        25674
  test_old/OLD_compare_similar_set              107336 ns       106814 ns         6611
  test_new/NEW_compare_similar_set               23795 ns        23757 ns        29510
  test_old/OLD_compare_big_set                87814006 ns     87564750 ns            8
  test_new/NEW_compare_big_set                77258477 ns     77124000 ns            9
  test_old/OLD_compare_big_set_different      86371487 ns     86087222 ns            9
  test_new/NEW_compare_big_set_different      79709931 ns     79506000 ns            8
  test_old/OLD_compare_oposite_order_set     351100203 ns    349060500 ns            2
  test_new/NEW_compare_oposite_order_set     312774516 ns    312366000 ns            2
  test_old/OLD_compare_random_set             11675568 ns     11655017 ns           58
  test_new/NEW_compare_random_set              3614458 ns      3611199 ns          196
  test_old/OLD_compare_random_set_different       2807 ns         2802 ns       229585
  test_new/NEW_compare_random_set_different       3031 ns         3022 ns       241292
  test_old/OLD_compare_short_string            2557198 ns      2545343 ns          274
  test_new/NEW_compare_short_string             739160 ns       736574 ns          976
  test_old/OLD_compare_long_string            17619450 ns     17561594 ns           32
  test_new/NEW_compare_long_string             2347907 ns      2343063 ns          284
  test_old/OLD_compare_different_strings           134 ns          133 ns      5265256
  test_new/NEW_compare_different_strings           147 ns          146 ns      4736707



================
Comment at: include/unordered_map:2280
+        if (!(*__first1 == *__first2))
+            goto __not_done;
+    return true;
----------------
EricWF wrote:
> You can write this without goto.
Yep. It requires one more comparison, but I think it is worth it. We should probably also update `is_permutation` so that it can eventually be a `constexpr`.


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

https://reviews.llvm.org/D61878





More information about the libcxx-commits mailing list