[libcxx-commits] [libcxx] 0e03c62 - [libc++] [bench] Stop using uniform_int_distribution<char> in benchmarks.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 17 11:31:50 PST 2022
Author: Arthur O'Dwyer
Date: 2022-01-17T14:31:33-05:00
New Revision: 0e03c62b4c86059fc35b8ce6c087c22a55f43e36
URL: https://github.com/llvm/llvm-project/commit/0e03c62b4c86059fc35b8ce6c087c22a55f43e36
DIFF: https://github.com/llvm/llvm-project/commit/0e03c62b4c86059fc35b8ce6c087c22a55f43e36.diff
LOG: [libc++] [bench] Stop using uniform_int_distribution<char> in benchmarks.
Reviewed as part of D114920.
Added:
Modified:
libcxx/benchmarks/GenerateInput.h
libcxx/benchmarks/algorithms.partition_point.bench.cpp
libcxx/benchmarks/allocation.bench.cpp
Removed:
################################################################################
diff --git a/libcxx/benchmarks/GenerateInput.h b/libcxx/benchmarks/GenerateInput.h
index e4f131c628f1f..3e63f8413303f 100644
--- a/libcxx/benchmarks/GenerateInput.h
+++ b/libcxx/benchmarks/GenerateInput.h
@@ -36,10 +36,9 @@ inline char getRandomChar() {
}
template <class IntT>
-inline IntT getRandomInteger(IntT Min = 0,
- IntT Max = std::numeric_limits<IntT>::max()) {
- std::uniform_int_distribution<IntT> dist(Min, Max);
- return dist(getRandomEngine());
+inline IntT getRandomInteger(IntT Min, IntT Max) {
+ std::uniform_int_distribution<unsigned long long> dist(Min, Max);
+ return static_cast<IntT>(dist(getRandomEngine()));
}
inline std::string getRandomString(std::size_t Len) {
@@ -102,7 +101,7 @@ template <class IntT>
std::vector<IntT> getRandomIntegerInputs(size_t N) {
std::vector<IntT> inputs;
for (size_t i=0; i < N; ++i) {
- inputs.push_back(getRandomInteger<IntT>());
+ inputs.push_back(getRandomInteger<IntT>(0, std::numeric_limits<IntT>::max()));
}
return inputs;
}
diff --git a/libcxx/benchmarks/algorithms.partition_point.bench.cpp b/libcxx/benchmarks/algorithms.partition_point.bench.cpp
index 840cf0391ee1c..8192f97206d9b 100644
--- a/libcxx/benchmarks/algorithms.partition_point.bench.cpp
+++ b/libcxx/benchmarks/algorithms.partition_point.bench.cpp
@@ -30,7 +30,7 @@ struct TestIntBase {
static std::vector<IntT> generateInput(size_t size) {
std::vector<IntT> Res(size);
std::generate(Res.begin(), Res.end(),
- [] { return getRandomInteger<IntT>(); });
+ [] { return getRandomInteger<IntT>(0, std::numeric_limits<IntT>::max()); });
return Res;
}
};
diff --git a/libcxx/benchmarks/allocation.bench.cpp b/libcxx/benchmarks/allocation.bench.cpp
index 236e74044a56f..ad962de5bf1fb 100644
--- a/libcxx/benchmarks/allocation.bench.cpp
+++ b/libcxx/benchmarks/allocation.bench.cpp
@@ -97,7 +97,6 @@ static void BM_DeallocateOnly(benchmark::State& st) {
const size_t alloc_size = st.range(0);
const auto NumAllocs = st.max_iterations;
- using PtrT = void*;
std::vector<void*> Pointers(NumAllocs);
for (auto& p : Pointers) {
p = AllocWrapper::Allocate(alloc_size);
More information about the libcxx-commits
mailing list