aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/microbenchmarks
diff options
context:
space:
mode:
authorGravatar Noah Eisen <ncteisen@google.com>2018-02-09 09:16:55 -0800
committerGravatar Noah Eisen <ncteisen@google.com>2018-02-09 09:16:55 -0800
commitbe82e64b3debcdb1d9ec6a149fc85af0d46bfb7e (patch)
treecc5e1234073eb250a2c319b5a4db2919fce060ea /test/cpp/microbenchmarks
parent194436342137924b4fb7429bede037a4b5ec7edb (diff)
Autofix c casts to c++ casts
Diffstat (limited to 'test/cpp/microbenchmarks')
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc6
-rw-r--r--test/cpp/microbenchmarks/bm_cq_multiple_threads.cc4
-rw-r--r--test/cpp/microbenchmarks/fullstack_context_mutators.h4
-rw-r--r--test/cpp/microbenchmarks/fullstack_fixtures.h4
-rw-r--r--test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h24
-rw-r--r--test/cpp/microbenchmarks/fullstack_streaming_pump.h10
-rw-r--r--test/cpp/microbenchmarks/fullstack_unary_ping_pong.h2
-rw-r--r--test/cpp/microbenchmarks/helpers.cc6
8 files changed, 30 insertions, 30 deletions
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
index 4b7310389c..3fe709ff83 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -82,7 +82,7 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
static_cast<uint32_t>(state.iterations()),
true,
false,
- (size_t)1024,
+ static_cast<size_t>(1024),
&stats,
};
grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
@@ -131,7 +131,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
static_cast<uint32_t>(state.iterations()),
state.range(0) != 0,
Fixture::kEnableTrueBinary,
- (size_t)state.range(1),
+ static_cast<size_t>(state.range(1)),
&stats,
};
grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
@@ -777,7 +777,7 @@ static void OnHeaderNew(void* user_data, grpc_mdelem md) {
if (GRPC_MDELEM_IS_INTERNED(md)) {
/* not already parsed: parse it now, and store the
* result away */
- cached_timeout = (grpc_millis*)gpr_malloc(sizeof(grpc_millis));
+ cached_timeout = static_cast<grpc_millis*>(gpr_malloc(sizeof(grpc_millis)));
*cached_timeout = timeout;
grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
}
diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
index 874c834931..7b236d94b6 100644
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
@@ -38,7 +38,7 @@ namespace testing {
auto& force_library_initialization = Library::get();
-static void* g_tag = (void*)(intptr_t)10; // Some random number
+static void* g_tag = (void*)static_cast<intptr_t>(10); // Some random number
static grpc_completion_queue* g_cq;
static grpc_event_engine_vtable g_vtable;
static const grpc_event_engine_vtable* g_old_vtable;
@@ -75,7 +75,7 @@ static grpc_error* pollset_work(grpc_pollset* ps, grpc_pollset_worker** worker,
gpr_mu_unlock(&ps->mu);
GPR_ASSERT(grpc_cq_begin_op(g_cq, g_tag));
grpc_cq_end_op(g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, nullptr,
- (grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
+ static_cast<grpc_cq_completion*>(gpr_malloc(sizeof(grpc_cq_completion))));
grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&ps->mu);
return GRPC_ERROR_NONE;
diff --git a/test/cpp/microbenchmarks/fullstack_context_mutators.h b/test/cpp/microbenchmarks/fullstack_context_mutators.h
index cafbeffdbe..3584280c48 100644
--- a/test/cpp/microbenchmarks/fullstack_context_mutators.h
+++ b/test/cpp/microbenchmarks/fullstack_context_mutators.h
@@ -72,7 +72,7 @@ class RandomBinaryMetadata {
grpc::string s;
s.reserve(length + 1);
for (int i = 0; i < length; i++) {
- s += (char)rand();
+ s += static_cast<char>(rand());
}
return s;
}
@@ -95,7 +95,7 @@ class RandomAsciiMetadata {
grpc::string s;
s.reserve(length + 1);
for (int i = 0; i < length; i++) {
- s += (char)(rand() % 26 + 'a');
+ s += static_cast<char>(rand() % 26 + 'a');
}
return s;
}
diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h
index fdc04e51c6..ce9731b7a6 100644
--- a/test/cpp/microbenchmarks/fullstack_fixtures.h
+++ b/test/cpp/microbenchmarks/fullstack_fixtures.h
@@ -108,7 +108,7 @@ class FullstackFixture : public BaseFixture {
void AddToLabel(std::ostream& out, benchmark::State& state) {
BaseFixture::AddToLabel(out, state);
out << " polls/iter:"
- << (double)grpc_get_cq_poll_num(this->cq()->cq()) / state.iterations();
+ << static_cast<double>(grpc_get_cq_poll_num(this->cq()->cq())) / state.iterations();
}
ServerCompletionQueue* cq() { return cq_.get(); }
@@ -236,7 +236,7 @@ class EndpointPairFixture : public BaseFixture {
void AddToLabel(std::ostream& out, benchmark::State& state) {
BaseFixture::AddToLabel(out, state);
out << " polls/iter:"
- << (double)grpc_get_cq_poll_num(this->cq()->cq()) / state.iterations();
+ << static_cast<double>(grpc_get_cq_poll_num(this->cq()->cq())) / state.iterations();
}
ServerCompletionQueue* cq() { return cq_.get(); }
diff --git a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h
index 0763d07855..f399949a32 100644
--- a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h
+++ b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h
@@ -83,7 +83,7 @@ static void BM_StreamingPingPong(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -99,7 +99,7 @@ static void BM_StreamingPingPong(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
// If server recv is complete, start the server send operation
if (i == 1) {
@@ -122,7 +122,7 @@ static void BM_StreamingPingPong(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1) | (1 << 2);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -175,7 +175,7 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -190,7 +190,7 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
// If server recv is complete, start the server send operation
if (i == 1) {
@@ -210,7 +210,7 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1) | (1 << 2);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -297,10 +297,10 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
// established). It is necessary when client init metadata is
// coalesced
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- while ((int)(intptr_t)t != 0) {
+ while (static_cast<int>((intptr_t)t) != 0) {
// In some cases tag:2 comes before tag:0 (write tag comes out
// first), this while loop is to make sure get tag:0.
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(await_tags & (1 << i));
await_tags &= ~(1 << i);
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
@@ -317,7 +317,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
while (await_tags != 0) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
// If server recv is complete, start the server send operation
if (i == 3) {
@@ -367,8 +367,8 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
// wait for server call data structure(call_hook, etc.) to be
// initialized, since initial metadata is corked.
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- while ((int)(intptr_t)t != 0) {
- int i = (int)(intptr_t)t;
+ while (static_cast<int>((intptr_t)t) != 0) {
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(expect_tags & (1 << i));
expect_tags &= ~(1 << i);
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
@@ -385,7 +385,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
while (expect_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(expect_tags & (1 << i));
expect_tags &= ~(1 << i);
}
diff --git a/test/cpp/microbenchmarks/fullstack_streaming_pump.h b/test/cpp/microbenchmarks/fullstack_streaming_pump.h
index 9e826091ec..3623e373f6 100644
--- a/test/cpp/microbenchmarks/fullstack_streaming_pump.h
+++ b/test/cpp/microbenchmarks/fullstack_streaming_pump.h
@@ -62,7 +62,7 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -85,7 +85,7 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -95,7 +95,7 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -131,7 +131,7 @@ static void BM_PumpStreamServerToClient(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -154,7 +154,7 @@ static void BM_PumpStreamServerToClient(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
diff --git a/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h b/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h
index d448938295..a85c33c320 100644
--- a/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h
+++ b/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h
@@ -91,7 +91,7 @@ static void BM_UnaryPingPong(benchmark::State& state) {
for (int i = (1 << 3) | (1 << 4); i != 0;) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int tagnum = (int)reinterpret_cast<intptr_t>(t);
+ int tagnum = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(i & (1 << tagnum));
i -= 1 << tagnum;
}
diff --git a/test/cpp/microbenchmarks/helpers.cc b/test/cpp/microbenchmarks/helpers.cc
index a4c0a3a0ce..25a033f104 100644
--- a/test/cpp/microbenchmarks/helpers.cc
+++ b/test/cpp/microbenchmarks/helpers.cc
@@ -44,17 +44,17 @@ void TrackCounters::AddToLabel(std::ostream& out, benchmark::State& state) {
grpc_stats_diff(&stats_end, &stats_begin_, &stats);
for (int i = 0; i < GRPC_STATS_COUNTER_COUNT; i++) {
out << " " << grpc_stats_counter_name[i]
- << "/iter:" << ((double)stats.counters[i] / (double)state.iterations());
+ << "/iter:" << (static_cast<double>(stats.counters[i]) / static_cast<double>(state.iterations()));
}
for (int i = 0; i < GRPC_STATS_HISTOGRAM_COUNT; i++) {
std::ostringstream median_ss;
median_ss << grpc_stats_histogram_name[i] << "-median";
state.counters[median_ss.str()] = benchmark::Counter(
- grpc_stats_histo_percentile(&stats, (grpc_stats_histograms)i, 50.0));
+ grpc_stats_histo_percentile(&stats, static_cast<grpc_stats_histograms>(i), 50.0));
std::ostringstream tail_ss;
tail_ss << grpc_stats_histogram_name[i] << "-99p";
state.counters[tail_ss.str()] = benchmark::Counter(
- grpc_stats_histo_percentile(&stats, (grpc_stats_histograms)i, 99.0));
+ grpc_stats_histo_percentile(&stats, static_cast<grpc_stats_histograms>(i), 99.0));
}
#ifdef GPR_LOW_LEVEL_COUNTERS
grpc_memory_counters counters_at_end = grpc_memory_counters_snapshot();