3 * Copyright 2016 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 /* Benchmark gRPC end2end in various configurations */
21 #include "test/cpp/microbenchmarks/fullstack_unary_ping_pong.h"
22 #include "test/cpp/util/test_config.h"
27 // force library initialization
28 auto& force_library_initialization = Library::get();
30 /*******************************************************************************
34 // Replace "benchmark::internal::Benchmark" with "::testing::Benchmark" to use
35 // internal microbenchmarking tooling
36 static void SweepSizesArgs(benchmark::internal::Benchmark* b) {
38 for (int i = 1; i <= 128 * 1024 * 1024; i *= 8) {
45 BENCHMARK_TEMPLATE(BM_UnaryPingPong, TCP, NoOpMutator, NoOpMutator)
46 ->Apply(SweepSizesArgs);
47 BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinTCP, NoOpMutator, NoOpMutator)
48 ->Apply(SweepSizesArgs);
49 BENCHMARK_TEMPLATE(BM_UnaryPingPong, UDS, NoOpMutator, NoOpMutator)
51 BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinUDS, NoOpMutator, NoOpMutator)
53 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator, NoOpMutator)
54 ->Apply(SweepSizesArgs);
55 BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinInProcess, NoOpMutator, NoOpMutator)
56 ->Apply(SweepSizesArgs);
57 BENCHMARK_TEMPLATE(BM_UnaryPingPong, SockPair, NoOpMutator, NoOpMutator)
59 BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinSockPair, NoOpMutator, NoOpMutator)
61 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, NoOpMutator)
62 ->Apply(SweepSizesArgs);
63 BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinInProcessCHTTP2, NoOpMutator,
65 ->Apply(SweepSizesArgs);
66 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
67 Client_AddMetadata<RandomBinaryMetadata<10>, 1>, NoOpMutator)
69 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
70 Client_AddMetadata<RandomBinaryMetadata<31>, 1>, NoOpMutator)
72 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
73 Client_AddMetadata<RandomBinaryMetadata<100>, 1>,
76 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
77 Client_AddMetadata<RandomBinaryMetadata<10>, 2>, NoOpMutator)
79 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
80 Client_AddMetadata<RandomBinaryMetadata<31>, 2>, NoOpMutator)
82 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
83 Client_AddMetadata<RandomBinaryMetadata<100>, 2>,
86 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
87 Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>)
89 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
90 Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>)
92 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
93 Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>)
95 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
96 Client_AddMetadata<RandomAsciiMetadata<10>, 1>, NoOpMutator)
98 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
99 Client_AddMetadata<RandomAsciiMetadata<31>, 1>, NoOpMutator)
101 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
102 Client_AddMetadata<RandomAsciiMetadata<100>, 1>, NoOpMutator)
104 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
105 Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>)
107 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
108 Server_AddInitialMetadata<RandomAsciiMetadata<31>, 1>)
110 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
111 Server_AddInitialMetadata<RandomAsciiMetadata<100>, 1>)
113 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
114 Server_AddInitialMetadata<RandomAsciiMetadata<10>, 100>)
116 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
117 Client_AddMetadata<RandomBinaryMetadata<10>, 1>, NoOpMutator)
119 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
120 Client_AddMetadata<RandomBinaryMetadata<31>, 1>, NoOpMutator)
122 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
123 Client_AddMetadata<RandomBinaryMetadata<100>, 1>,
126 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
127 Client_AddMetadata<RandomBinaryMetadata<10>, 2>, NoOpMutator)
129 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
130 Client_AddMetadata<RandomBinaryMetadata<31>, 2>, NoOpMutator)
132 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
133 Client_AddMetadata<RandomBinaryMetadata<100>, 2>,
136 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
137 Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>)
139 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
140 Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>)
142 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
143 Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>)
145 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
146 Client_AddMetadata<RandomAsciiMetadata<10>, 1>, NoOpMutator)
148 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
149 Client_AddMetadata<RandomAsciiMetadata<31>, 1>, NoOpMutator)
151 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
152 Client_AddMetadata<RandomAsciiMetadata<100>, 1>, NoOpMutator)
154 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
155 Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>)
157 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
158 Server_AddInitialMetadata<RandomAsciiMetadata<31>, 1>)
160 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
161 Server_AddInitialMetadata<RandomAsciiMetadata<100>, 1>)
163 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
164 Server_AddInitialMetadata<RandomAsciiMetadata<10>, 100>)
167 } // namespace testing
170 // Some distros have RunSpecifiedBenchmarks under the benchmark namespace,
171 // and others do not. This allows us to support both modes.
172 namespace benchmark {
173 void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); }
174 } // namespace benchmark
176 int main(int argc, char** argv) {
177 ::benchmark::Initialize(&argc, argv);
178 ::grpc::testing::InitTest(&argc, &argv, false);
179 benchmark::RunTheBenchmarksNamespaced();