From 582c687b4ca18899e811dfbad3075d5b2a2c46df Mon Sep 17 00:00:00 2001 From: vjpai <vpai@google.com> Date: Mon, 27 Jul 2015 16:39:28 -0700 Subject: [PATCH] Remove use of C++11 randomization engines --- test/cpp/qps/interarrival.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/cpp/qps/interarrival.h b/test/cpp/qps/interarrival.h index f90a17a894..a4fecb7bab 100644 --- a/test/cpp/qps/interarrival.h +++ b/test/cpp/qps/interarrival.h @@ -36,7 +36,8 @@ #include <chrono> #include <cmath> -#include <random> +#include <cstdlib> +#include <vector> #include <grpc++/config.h> @@ -141,17 +142,16 @@ class ParetoDist GRPC_FINAL : public RandomDist { // in an efficient re-entrant way. The random table is built at construction // time, and each call must include the thread id of the invoker -typedef std::default_random_engine qps_random_engine; - class InterarrivalTimer { public: InterarrivalTimer() {} void init(const RandomDist& r, int threads, int entries = 1000000) { - qps_random_engine gen; - std::uniform_real_distribution<double> uniform(0.0, 1.0); 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 + double uniform_0_1 = rand() / RAND_MAX; random_table_.push_back(std::chrono::nanoseconds( - static_cast<int64_t>(1e9 * r(uniform(gen))))); + static_cast<int64_t>(1e9 * r(uniform_0_1)))); } // Now set up the thread positions for (int i = 0; i < threads; i++) { -- GitLab