aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps/interarrival.h
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-08-31 10:54:11 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-08-31 10:54:11 -0700
commit8fd40d5ed9303c693865ff431b7565173a4b898e (patch)
tree5d3f6ce958de74e79a8bbaf71b7eb8bbd8acfecd /test/cpp/qps/interarrival.h
parentc9c78ee96c5a73234513decd398a63d48f14aa89 (diff)
parent8d51e8d17e012f81ca8e94c18f525e1781130481 (diff)
Merge github.com:grpc/grpc into wc
Diffstat (limited to 'test/cpp/qps/interarrival.h')
-rw-r--r--test/cpp/qps/interarrival.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/test/cpp/qps/interarrival.h b/test/cpp/qps/interarrival.h
index c6e417985a..1fa310c209 100644
--- a/test/cpp/qps/interarrival.h
+++ b/test/cpp/qps/interarrival.h
@@ -21,7 +21,7 @@
#include <chrono>
#include <cmath>
-#include <cstdlib>
+#include <random>
#include <vector>
#include <grpc++/support/config.h>
@@ -75,13 +75,13 @@ class InterarrivalTimer {
public:
InterarrivalTimer() {}
void init(const RandomDistInterface& r, int threads, int entries = 1000000) {
+ std::random_device devrand;
+ std::mt19937_64 generator(devrand());
+ std::uniform_real_distribution<double> rando(0, 1);
for (int i = 0; i < entries; i++) {
- // rand is the only choice that is portable across POSIX and Windows
- // and that supports new and old compilers
- const double uniform_0_1 =
- static_cast<double>(rand()) / static_cast<double>(RAND_MAX);
random_table_.push_back(
- static_cast<int64_t>(1e9 * r.transform(uniform_0_1)));
+ static_cast<int64_t>(1e9 * r.transform(rando(generator))));
+ ;
}
// Now set up the thread positions
for (int i = 0; i < threads; i++) {