diff options
author | Craig Tiller <ctiller@google.com> | 2016-09-29 10:10:00 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-09-29 10:10:00 -0700 |
commit | 032f9bfb584f006841a051305f16b53550cf7ca3 (patch) | |
tree | 8c13dea92eec9d9e76a303ef44a5c87143eaa7f4 /test/cpp | |
parent | 091e4f0ef83cdd1115f0a799a5c0dccfae03316c (diff) |
Start to log errors from benchmark
Diffstat (limited to 'test/cpp')
-rw-r--r-- | test/cpp/qps/client.h | 21 | ||||
-rw-r--r-- | test/cpp/qps/client_async.cc | 11 |
2 files changed, 23 insertions, 9 deletions
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 833bb2bad5..100d038ff2 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -115,17 +115,25 @@ class ClientRequestCreator<ByteBuffer> { class HistogramEntry GRPC_FINAL { public: - HistogramEntry() : used_(false) {} - bool used() const { return used_; } + HistogramEntry() : value_used_(false), status_used_(false) {} + bool value_used() const { return value_used_; } double value() const { return value_; } void set_value(double v) { - used_ = true; + value_used_ = true; value_ = v; } + bool status_used() const { return status_used_; } + int status() const { return status_; } + void set_status(int status) { + status_used_ = true; + status_ = status; + } private: - bool used_; + bool value_used_; double value_; + bool status_used_; + int status_; }; typedef std::unordered_map<int, int64_t> StatusHistogram; @@ -309,9 +317,12 @@ class Client { const bool thread_still_ok = client_->ThreadFunc(&entry, idx_); // lock, update histogram if needed and see if we're done std::lock_guard<std::mutex> g(mu_); - if (entry.used()) { + if (entry.value_used()) { histogram_.Add(entry.value()); } + if (entry.status_used()) { + statuses_[entry.value()]++; + } if (!thread_still_ok) { gpr_log(GPR_ERROR, "Finishing client thread due to RPC error"); } diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index 5d9cb4bd0c..572a85e58e 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -83,7 +83,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&, CompletionQueue*)> start_req, - std::function<void(grpc::Status, ResponseType*)> on_done) + std::function<void(grpc::Status, ResponseType*, HistogramEntry*)> on_done) : context_(), stub_(stub), cq_(nullptr), @@ -113,7 +113,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { return true; case State::RESP_DONE: entry->set_value((UsageTimer::Now() - start_) * 1e9); - callback_(status_, &response_); + callback_(status_, &response_, entry); next_state_ = State::INVALID; return false; default: @@ -135,7 +135,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { ResponseType response_; enum State { INVALID, READY, RESP_DONE }; State next_state_; - std::function<void(grpc::Status, ResponseType*)> callback_; + std::function<void(grpc::Status, ResponseType*, HistogramEntry*)> callback_; std::function<gpr_timespec()> next_issue_; std::function<std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>>( BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&, @@ -289,7 +289,10 @@ class AsyncUnaryClient GRPC_FINAL ~AsyncUnaryClient() GRPC_OVERRIDE {} private: - static void CheckDone(grpc::Status s, SimpleResponse* response) {} + static void CheckDone(grpc::Status s, SimpleResponse* response, + HistogramEntry* entry) { + entry->set_status(s.error_code()); + } static std::unique_ptr<grpc::ClientAsyncResponseReader<SimpleResponse>> StartReq(BenchmarkService::Stub* stub, grpc::ClientContext* ctx, const SimpleRequest& request, CompletionQueue* cq) { |