aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps/server.h
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2016-01-13 11:15:49 -0800
committerGravatar Vijay Pai <vpai@google.com>2016-01-13 11:15:49 -0800
commit0e66efdaddf096f9833ca37e7eee958b2316242f (patch)
treea5b58da72a12291036705e34ce1e933ce4514a8f /test/cpp/qps/server.h
parent0ade2d415ff5dbc9fca7b942809ef7179db08ef7 (diff)
Make core limitation work for both client and server so that we can run tests on the same
machine if desired. The core_list flags to qps_driver are comma-separated lists of core numbers.
Diffstat (limited to 'test/cpp/qps/server.h')
-rw-r--r--test/cpp/qps/server.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h
index 620bc32f4b..474473a7d0 100644
--- a/test/cpp/qps/server.h
+++ b/test/cpp/qps/server.h
@@ -34,11 +34,13 @@
#ifndef TEST_QPS_SERVER_H
#define TEST_QPS_SERVER_H
+#include <vector>
#include <grpc/support/cpu.h>
#include <grpc++/security/server_credentials.h>
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/port.h"
+#include "test/cpp/qps/coresched.h"
#include "test/cpp/qps/timer.h"
#include "src/proto/grpc/testing/messages.grpc.pb.h"
#include "src/proto/grpc/testing/control.grpc.pb.h"
@@ -49,6 +51,16 @@ namespace testing {
class Server {
public:
explicit Server(const ServerConfig& config) : timer_(new Timer) {
+ int clsize = config.core_list_size();
+ if (clsize > 0) {
+ std::vector<int> core_list;
+ for (int i = 0; i < clsize; i++) {
+ core_list.push_back(config.core_list(i));
+ }
+ cores_ = LimitCores(core_list);
+ } else {
+ cores_ = gpr_cpu_num_cores();
+ }
if (config.port()) {
port_ = config.port();
} else {
@@ -87,7 +99,7 @@ class Server {
}
int port() const { return port_; }
- int cores() const { return gpr_cpu_num_cores(); }
+ int cores() const { return cores_;}
static std::shared_ptr<ServerCredentials> CreateServerCredentials(
const ServerConfig& config) {
if (config.has_security_params()) {
@@ -104,6 +116,7 @@ class Server {
private:
int port_;
+ int cores_;
std::unique_ptr<Timer> timer_;
};