diff options
author | 2018-01-30 19:12:59 +0100 | |
---|---|---|
committer | 2018-01-30 19:24:56 +0100 | |
commit | 12ba4b1e05ca420008c38234e13c5540b3b704c0 (patch) | |
tree | d26aae57f7b32e92ae15d76a0ab3ebf20c22893e /test/cpp | |
parent | e6cf0aeff4979e5ff2501e7fe5e2fdf926350452 (diff) |
make grpc_passthru_endpoint_stats refcounted
Diffstat (limited to 'test/cpp')
-rw-r--r-- | test/cpp/microbenchmarks/bm_fullstack_trickle.cc | 13 | ||||
-rw-r--r-- | test/cpp/microbenchmarks/fullstack_fixtures.h | 13 | ||||
-rw-r--r-- | test/cpp/performance/writes_per_rpc_test.cc | 13 |
3 files changed, 30 insertions, 9 deletions
diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc index d6d7d41e5e..07a8102915 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc @@ -101,9 +101,11 @@ class TrickledCHTTP2 : public EndpointPairFixture { } } + virtual ~TrickledCHTTP2() { grpc_passthru_endpoint_stats_destroy(stats_); } + void AddToLabel(std::ostream& out, benchmark::State& state) { out << " writes/iter:" - << ((double)stats_.num_writes / (double)state.iterations()) + << ((double)stats_->num_writes / (double)state.iterations()) << " cli_transport_stalls/iter:" << ((double) client_stats_.streams_stalled_due_to_transport_flow_control / @@ -193,7 +195,7 @@ class TrickledCHTTP2 : public EndpointPairFixture { } private: - grpc_passthru_endpoint_stats stats_; + grpc_passthru_endpoint_stats* stats_; struct Stats { int streams_stalled_due_to_stream_flow_control = 0; int streams_stalled_due_to_transport_flow_control = 0; @@ -204,9 +206,14 @@ class TrickledCHTTP2 : public EndpointPairFixture { gpr_timespec start_ = gpr_now(GPR_CLOCK_MONOTONIC); grpc_endpoint_pair MakeEndpoints(size_t kilobits) { + stats_ = grpc_passthru_endpoint_stats_create(); // is there a better way to + // initialize stats_ and + // pass MakeEndpoints's + // return value to base + // constructor? grpc_endpoint_pair p; grpc_passthru_endpoint_create(&p.client, &p.server, Library::get().rq(), - &stats_); + stats_); double bytes_per_second = 125.0 * kilobits; p.client = grpc_trickle_endpoint_create(p.client, bytes_per_second); p.server = grpc_trickle_endpoint_create(p.server, bytes_per_second); diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index d1ede755a5..7e93cbd74d 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -252,20 +252,27 @@ class InProcessCHTTP2 : public EndpointPairFixture { FixtureConfiguration()) : EndpointPairFixture(service, MakeEndpoints(), fixture_configuration) {} + virtual ~InProcessCHTTP2() { grpc_passthru_endpoint_stats_destroy(stats_); } + void AddToLabel(std::ostream& out, benchmark::State& state) { EndpointPairFixture::AddToLabel(out, state); out << " writes/iter:" - << static_cast<double>(gpr_atm_no_barrier_load(&stats_.num_writes)) / + << static_cast<double>(gpr_atm_no_barrier_load(&stats_->num_writes)) / static_cast<double>(state.iterations()); } private: - grpc_passthru_endpoint_stats stats_; + grpc_passthru_endpoint_stats* stats_; grpc_endpoint_pair MakeEndpoints() { + stats_ = grpc_passthru_endpoint_stats_create(); // is there a better way to + // initialize stats_ and + // pass MakeEndpoints's + // return value to base + // constructor? grpc_endpoint_pair p; grpc_passthru_endpoint_create(&p.client, &p.server, Library::get().rq(), - &stats_); + stats_); return p; } }; diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc index 0b9dc83f2b..0866b58f58 100644 --- a/test/cpp/performance/writes_per_rpc_test.cc +++ b/test/cpp/performance/writes_per_rpc_test.cc @@ -145,15 +145,22 @@ class InProcessCHTTP2 : public EndpointPairFixture { InProcessCHTTP2(Service* service) : EndpointPairFixture(service, MakeEndpoints()) {} - int writes_performed() const { return stats_.num_writes; } + virtual ~InProcessCHTTP2() { grpc_passthru_endpoint_stats_destroy(stats_); } + + int writes_performed() const { return stats_->num_writes; } private: - grpc_passthru_endpoint_stats stats_; + grpc_passthru_endpoint_stats* stats_; grpc_endpoint_pair MakeEndpoints() { + stats_ = grpc_passthru_endpoint_stats_create(); // is there a better way to + // initialize stats_ and + // pass MakeEndpoints's + // return value to base + // constructor? grpc_endpoint_pair p; grpc_passthru_endpoint_create(&p.client, &p.server, initialize_stuff.rq(), - &stats_); + stats_); return p; } }; |