• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
21 #include "test/cpp/microbenchmarks/fullstack_unary_ping_pong.h"
22 #include "test/cpp/util/test_config.h"
23 
24 namespace grpc {
25 namespace testing {
26 
27 // force library initialization
28 auto& force_library_initialization = Library::get();
29 
30 /*******************************************************************************
31  * CONFIGURATIONS
32  */
33 
SweepSizesArgs(benchmark::internal::Benchmark * b)34 static void SweepSizesArgs(benchmark::internal::Benchmark* b) {
35   b->Args({0, 0});
36   for (int i = 1; i <= 128 * 1024 * 1024; i *= 8) {
37     b->Args({i, 0});
38     b->Args({0, i});
39     b->Args({i, i});
40   }
41 }
42 
43 BENCHMARK_TEMPLATE(BM_UnaryPingPong, TCP, NoOpMutator, NoOpMutator)
44     ->Apply(SweepSizesArgs);
45 BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinTCP, NoOpMutator, NoOpMutator)
46     ->Apply(SweepSizesArgs);
47 BENCHMARK_TEMPLATE(BM_UnaryPingPong, UDS, NoOpMutator, NoOpMutator)
48     ->Args({0, 0});
49 BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinUDS, NoOpMutator, NoOpMutator)
50     ->Args({0, 0});
51 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator, NoOpMutator)
52     ->Apply(SweepSizesArgs);
53 BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinInProcess, NoOpMutator, NoOpMutator)
54     ->Apply(SweepSizesArgs);
55 BENCHMARK_TEMPLATE(BM_UnaryPingPong, SockPair, NoOpMutator, NoOpMutator)
56     ->Args({0, 0});
57 BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinSockPair, NoOpMutator, NoOpMutator)
58     ->Args({0, 0});
59 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, NoOpMutator)
60     ->Apply(SweepSizesArgs);
61 BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinInProcessCHTTP2, NoOpMutator,
62                    NoOpMutator)
63     ->Apply(SweepSizesArgs);
64 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
65                    Client_AddMetadata<RandomBinaryMetadata<10>, 1>, NoOpMutator)
66     ->Args({0, 0});
67 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
68                    Client_AddMetadata<RandomBinaryMetadata<31>, 1>, NoOpMutator)
69     ->Args({0, 0});
70 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
71                    Client_AddMetadata<RandomBinaryMetadata<100>, 1>,
72                    NoOpMutator)
73     ->Args({0, 0});
74 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
75                    Client_AddMetadata<RandomBinaryMetadata<10>, 2>, NoOpMutator)
76     ->Args({0, 0});
77 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
78                    Client_AddMetadata<RandomBinaryMetadata<31>, 2>, NoOpMutator)
79     ->Args({0, 0});
80 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
81                    Client_AddMetadata<RandomBinaryMetadata<100>, 2>,
82                    NoOpMutator)
83     ->Args({0, 0});
84 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
85                    Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>)
86     ->Args({0, 0});
87 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
88                    Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>)
89     ->Args({0, 0});
90 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
91                    Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>)
92     ->Args({0, 0});
93 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
94                    Client_AddMetadata<RandomAsciiMetadata<10>, 1>, NoOpMutator)
95     ->Args({0, 0});
96 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
97                    Client_AddMetadata<RandomAsciiMetadata<31>, 1>, NoOpMutator)
98     ->Args({0, 0});
99 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
100                    Client_AddMetadata<RandomAsciiMetadata<100>, 1>, NoOpMutator)
101     ->Args({0, 0});
102 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
103                    Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>)
104     ->Args({0, 0});
105 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
106                    Server_AddInitialMetadata<RandomAsciiMetadata<31>, 1>)
107     ->Args({0, 0});
108 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
109                    Server_AddInitialMetadata<RandomAsciiMetadata<100>, 1>)
110     ->Args({0, 0});
111 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
112                    Server_AddInitialMetadata<RandomAsciiMetadata<10>, 100>)
113     ->Args({0, 0});
114 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
115                    Client_AddMetadata<RandomBinaryMetadata<10>, 1>, NoOpMutator)
116     ->Args({0, 0});
117 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
118                    Client_AddMetadata<RandomBinaryMetadata<31>, 1>, NoOpMutator)
119     ->Args({0, 0});
120 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
121                    Client_AddMetadata<RandomBinaryMetadata<100>, 1>,
122                    NoOpMutator)
123     ->Args({0, 0});
124 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
125                    Client_AddMetadata<RandomBinaryMetadata<10>, 2>, NoOpMutator)
126     ->Args({0, 0});
127 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
128                    Client_AddMetadata<RandomBinaryMetadata<31>, 2>, NoOpMutator)
129     ->Args({0, 0});
130 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
131                    Client_AddMetadata<RandomBinaryMetadata<100>, 2>,
132                    NoOpMutator)
133     ->Args({0, 0});
134 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
135                    Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>)
136     ->Args({0, 0});
137 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
138                    Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>)
139     ->Args({0, 0});
140 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
141                    Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>)
142     ->Args({0, 0});
143 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
144                    Client_AddMetadata<RandomAsciiMetadata<10>, 1>, NoOpMutator)
145     ->Args({0, 0});
146 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
147                    Client_AddMetadata<RandomAsciiMetadata<31>, 1>, NoOpMutator)
148     ->Args({0, 0});
149 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
150                    Client_AddMetadata<RandomAsciiMetadata<100>, 1>, NoOpMutator)
151     ->Args({0, 0});
152 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
153                    Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>)
154     ->Args({0, 0});
155 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
156                    Server_AddInitialMetadata<RandomAsciiMetadata<31>, 1>)
157     ->Args({0, 0});
158 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
159                    Server_AddInitialMetadata<RandomAsciiMetadata<100>, 1>)
160     ->Args({0, 0});
161 BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
162                    Server_AddInitialMetadata<RandomAsciiMetadata<10>, 100>)
163     ->Args({0, 0});
164 
165 }  // namespace testing
166 }  // namespace grpc
167 
168 // Some distros have RunSpecifiedBenchmarks under the benchmark namespace,
169 // and others do not. This allows us to support both modes.
170 namespace benchmark {
RunTheBenchmarksNamespaced()171 void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); }
172 }  // namespace benchmark
173 
main(int argc,char ** argv)174 int main(int argc, char** argv) {
175   ::benchmark::Initialize(&argc, argv);
176   ::grpc::testing::InitTest(&argc, &argv, false);
177   benchmark::RunTheBenchmarksNamespaced();
178   return 0;
179 }
180