[libcxx-commits] [libcxx] [libc++] Rewrite the std::lower_bound benchmark to be more efficient and add an upper_bound benchmark (PR #177180)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jan 21 07:18:00 PST 2026
================
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+#include <algorithm>
+#include <deque>
+#include <forward_list>
+#include <list>
+#include <numeric>
+#include <random>
+#include <vector>
+
+#include "benchmark/benchmark.h"
+#include "../../GenerateInput.h"
+
+void Sizes(auto benchmark) { benchmark->Arg(8)->Arg(100)->Arg(8192); }
+
+template <class Container>
+static void BM_lower_bound(benchmark::State& state) {
+ std::mt19937_64 rng{std::random_device{}()};
----------------
ldionne wrote:
I would rather seed the mersenne twister instead of using a random device.
https://github.com/llvm/llvm-project/pull/177180
More information about the libcxx-commits
mailing list