bm_fullstack_streaming_ping_pong.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /* Benchmark gRPC end2end in various configurations */
20 
24 
25 namespace grpc {
26 namespace testing {
27 
28 /*******************************************************************************
29  * CONFIGURATIONS
30  */
31 
32 // Generate Args for StreamingPingPong benchmarks. Currently generates args for
33 // only "small streams" (i.e streams with 0, 1 or 2 messages)
35  int msg_size = 0;
36 
37  b->Args({0, 0}); // spl case: 0 ping-pong msgs (msg_size doesn't matter here)
38 
39  for (msg_size = 0; msg_size <= 128 * 1024 * 1024;
40  msg_size == 0 ? msg_size++ : msg_size *= 8) {
41  b->Args({msg_size, 1});
42  b->Args({msg_size, 2});
43  }
44 }
45 
46 BENCHMARK_TEMPLATE(BM_StreamingPingPong, InProcessCHTTP2, NoOpMutator,
47  NoOpMutator)
48  ->Apply(StreamingPingPongArgs);
49 BENCHMARK_TEMPLATE(BM_StreamingPingPong, TCP, NoOpMutator, NoOpMutator)
50  ->Apply(StreamingPingPongArgs);
51 BENCHMARK_TEMPLATE(BM_StreamingPingPong, InProcess, NoOpMutator, NoOpMutator)
52  ->Apply(StreamingPingPongArgs);
53 
54 BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, InProcessCHTTP2, NoOpMutator,
55  NoOpMutator)
56  ->Range(0, 128 * 1024 * 1024);
57 BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, TCP, NoOpMutator, NoOpMutator)
58  ->Range(0, 128 * 1024 * 1024);
59 BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, InProcess, NoOpMutator,
60  NoOpMutator)
61  ->Range(0, 128 * 1024 * 1024);
62 
64  NoOpMutator)
65  ->Apply(StreamingPingPongArgs);
66 BENCHMARK_TEMPLATE(BM_StreamingPingPong, MinTCP, NoOpMutator, NoOpMutator)
67  ->Apply(StreamingPingPongArgs);
68 BENCHMARK_TEMPLATE(BM_StreamingPingPong, MinInProcess, NoOpMutator, NoOpMutator)
69  ->Apply(StreamingPingPongArgs);
70 
72  NoOpMutator)
73  ->Range(0, 128 * 1024 * 1024);
74 BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, MinTCP, NoOpMutator, NoOpMutator)
75  ->Range(0, 128 * 1024 * 1024);
77  NoOpMutator)
78  ->Range(0, 128 * 1024 * 1024);
79 
80 // Generate Args for StreamingPingPongWithCoalescingApi benchmarks. Currently
81 // generates args for only "small streams" (i.e streams with 0, 1 or 2 messages)
84  int msg_size = 0;
85 
86  b->Args(
87  {0, 0, 0}); // spl case: 0 ping-pong msgs (msg_size doesn't matter here)
88  b->Args(
89  {0, 0, 1}); // spl case: 0 ping-pong msgs (msg_size doesn't matter here)
90 
91  for (msg_size = 0; msg_size <= 128 * 1024 * 1024;
92  msg_size == 0 ? msg_size++ : msg_size *= 8) {
93  b->Args({msg_size, 1, 0});
94  b->Args({msg_size, 2, 0});
95  b->Args({msg_size, 1, 1});
96  b->Args({msg_size, 2, 1});
97  }
98 }
99 
101  NoOpMutator, NoOpMutator)
104  NoOpMutator, NoOpMutator)
107  NoOpMutator, NoOpMutator)
110  NoOpMutator, NoOpMutator)
112 
113 } // namespace testing
114 } // namespace grpc
115 
116 // Some distros have RunSpecifiedBenchmarks under the benchmark namespace,
117 // and others do not. This allows us to support both modes.
118 namespace benchmark {
120 } // namespace benchmark
121 
122 int main(int argc, char** argv) {
123  grpc::testing::TestEnvironment env(&argc, argv);
124  LibraryInitializer libInit;
125  ::benchmark::Initialize(&argc, argv);
126  grpc::testing::InitTest(&argc, &argv, false);
128  return 0;
129 }
grpc::testing::InitTest
void InitTest(int *argc, char ***argv, bool remove_flags)
Definition: test_config_cc.cc:28
grpc::testing::BM_StreamingPingPong
static void BM_StreamingPingPong(benchmark::State &state)
Definition: fullstack_streaming_ping_pong.h:50
testing
Definition: aws_request_signer_test.cc:25
benchmark
Definition: bm_alarm.cc:55
generate.env
env
Definition: generate.py:37
grpc
Definition: grpcpp/alarm.h:33
grpc::testing::MinInProcessCHTTP2
MinStackize< InProcessCHTTP2 > MinInProcessCHTTP2
Definition: fullstack_fixtures.h:332
grpc::testing::MinInProcess
MinStackize< InProcess > MinInProcess
Definition: fullstack_fixtures.h:330
benchmark::RunTheBenchmarksNamespaced
void RunTheBenchmarksNamespaced()
Definition: bm_alarm.cc:56
grpc::testing::BENCHMARK_TEMPLATE
BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, NoOpMutator) -> Apply(StreamingPingPongMsgSizeArgs)
grpc::testing::BM_StreamingPingPongMsgs
static void BM_StreamingPingPongMsgs(benchmark::State &state)
Definition: fullstack_streaming_ping_pong.h:144
benchmark::RunSpecifiedBenchmarks
size_t RunSpecifiedBenchmarks()
Definition: benchmark/src/benchmark.cc:437
main
int main(int argc, char **argv)
Definition: bm_fullstack_streaming_ping_pong.cc:122
grpc::testing::StreamingPingPongArgs
static void StreamingPingPongArgs(benchmark::internal::Benchmark *b)
Definition: bm_fullstack_streaming_ping_pong.cc:34
grpc::testing::StreamingPingPongWithCoalescingApiArgs
static void StreamingPingPongWithCoalescingApiArgs(benchmark::internal::Benchmark *b)
Definition: bm_fullstack_streaming_ping_pong.cc:82
benchmark::Initialize
void Initialize(int *argc, char **argv)
Definition: benchmark/src/benchmark.cc:602
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
benchmark::internal::Benchmark
Definition: benchmark/include/benchmark/benchmark.h:834
LibraryInitializer
Definition: helpers.h:33
test_config.h
fullstack_streaming_ping_pong.h
grpc::testing::BM_StreamingPingPongWithCoalescingApi
static void BM_StreamingPingPongWithCoalescingApi(benchmark::State &state)
Definition: fullstack_streaming_ping_pong.h:242
grpc::testing::TestEnvironment
Definition: test/core/util/test_config.h:54
grpc::testing::MinTCP
MinStackize< TCP > MinTCP
Definition: fullstack_fixtures.h:328
test_config.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:48