summaryrefslogtreecommitdiff
path: root/libcxx/benchmarks
diff options
context:
space:
mode:
authorArthur O'Dwyer <arthur.j.odwyer@gmail.com>2022-01-17 12:06:06 -0500
committerArthur O'Dwyer <arthur.j.odwyer@gmail.com>2022-01-17 14:31:33 -0500
commit0e03c62b4c86059fc35b8ce6c087c22a55f43e36 (patch)
tree2599ec53658d074255102b314d17f5e69f430ea0 /libcxx/benchmarks
parent01193cae1c8441f4ce8d21460d397942473f8c11 (diff)
downloadllvm-0e03c62b4c86059fc35b8ce6c087c22a55f43e36.tar.gz
[libc++] [bench] Stop using uniform_int_distribution<char> in benchmarks.
Reviewed as part of D114920.
Diffstat (limited to 'libcxx/benchmarks')
-rw-r--r--libcxx/benchmarks/GenerateInput.h9
-rw-r--r--libcxx/benchmarks/algorithms.partition_point.bench.cpp2
-rw-r--r--libcxx/benchmarks/allocation.bench.cpp1
3 files changed, 5 insertions, 7 deletions
diff --git a/libcxx/benchmarks/GenerateInput.h b/libcxx/benchmarks/GenerateInput.h
index e4f131c628f1..3e63f8413303 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 840cf0391ee1..8192f97206d9 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 236e74044a56..ad962de5bf1f 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);