diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2017-08-30 23:13:25 +0200 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2017-08-30 23:13:25 +0200 |
commit | 90df76b4633c6a3c8a492148ba5268b94284ea6a (patch) | |
tree | 91ec10271620b7d9baaf510bbfc11349bd4fa663 /test/cpp/qps | |
parent | 2bc5e3ac40fc1b6f7d329a1727c78e8a820d5cf6 (diff) | |
parent | 7a8488c4d2b0274c7c71cd15d39f0cf277a3a119 (diff) |
Merge branch 'master' of https://github.com/grpc/grpc into visibility
Diffstat (limited to 'test/cpp/qps')
-rw-r--r-- | test/cpp/qps/client.h | 29 | ||||
-rw-r--r-- | test/cpp/qps/client_async.cc | 1 | ||||
-rw-r--r-- | test/cpp/qps/interarrival.h | 12 | ||||
-rw-r--r-- | test/cpp/qps/server.h | 1 | ||||
-rw-r--r-- | test/cpp/qps/server_async.cc | 1 |
5 files changed, 17 insertions, 27 deletions
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 6c4d92e859..b1d90aa9c4 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -31,7 +31,6 @@ #include <grpc/support/log.h> #include <grpc/support/time.h> -#include "src/core/lib/surface/completion_queue.h" #include "src/proto/grpc/testing/payloads.pb.h" #include "src/proto/grpc/testing/services.grpc.pb.h" @@ -370,12 +369,11 @@ class ClientImpl : public Client { ClientImpl(const ClientConfig& config, std::function<std::unique_ptr<StubType>(std::shared_ptr<Channel>)> create_stub) - : cores_(gpr_cpu_num_cores()), - channels_(config.client_channels()), - create_stub_(create_stub) { + : cores_(gpr_cpu_num_cores()), create_stub_(create_stub) { for (int i = 0; i < config.client_channels(); i++) { - channels_[i].init(config.server_targets(i % config.server_targets_size()), - config, create_stub_, i); + channels_.emplace_back( + config.server_targets(i % config.server_targets_size()), config, + create_stub_, i); } ClientRequestCreator<RequestType> create_req(&request_, @@ -389,20 +387,11 @@ class ClientImpl : public Client { class ClientChannelInfo { public: - ClientChannelInfo() {} - ClientChannelInfo(const ClientChannelInfo& i) { - // The copy constructor is to satisfy old compilers - // that need it for using std::vector . It is only ever - // used for empty entries - GPR_ASSERT(!i.channel_ && !i.stub_); - } - void init(const grpc::string& target, const ClientConfig& config, - std::function<std::unique_ptr<StubType>(std::shared_ptr<Channel>)> - create_stub, - int shard) { - // We have to use a 2-phase init like this with a default - // constructor followed by an initializer function to make - // old compilers happy with using this in std::vector + ClientChannelInfo( + const grpc::string& target, const ClientConfig& config, + std::function<std::unique_ptr<StubType>(std::shared_ptr<Channel>)> + create_stub, + int shard) { ChannelArguments args; args.SetInt("shard_to_ensure_no_subchannel_merges", shard); set_channel_args(config, &args); diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index 265f174cc5..97e2aef914 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -34,6 +34,7 @@ #include <grpc/support/cpu.h> #include <grpc/support/log.h> +#include "src/core/lib/surface/completion_queue.h" #include "src/proto/grpc/testing/services.grpc.pb.h" #include "test/cpp/qps/client.h" #include "test/cpp/qps/usage_timer.h" 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++) { diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index df27a4368e..3d6f347cae 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -26,7 +26,6 @@ #include <grpc/support/log.h> #include <vector> -#include "src/core/lib/surface/completion_queue.h" #include "src/proto/grpc/testing/control.pb.h" #include "src/proto/grpc/testing/messages.pb.h" #include "test/core/end2end/data/ssl_test_data.h" diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 8b00bcfeaf..4a82f98199 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -35,6 +35,7 @@ #include <grpc/support/host_port.h> #include <grpc/support/log.h> +#include "src/core/lib/surface/completion_queue.h" #include "src/proto/grpc/testing/services.grpc.pb.h" #include "test/core/util/test_config.h" #include "test/cpp/qps/server.h" |