bm_callback_streaming_ping_pong.cc 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. #include "test/cpp/microbenchmarks/callback_streaming_ping_pong.h"
  19. #include "test/cpp/util/test_config.h"
  20. namespace grpc {
  21. namespace testing {
  22. // force library initialization
  23. auto& force_library_initialization = Library::get();
  24. /*******************************************************************************
  25. * CONFIGURATIONS
  26. */
  27. // Replace "benchmark::internal::Benchmark" with "::testing::Benchmark" to use
  28. // internal microbenchmarking tooling
  29. static void StreamingPingPongArgs(benchmark::internal::Benchmark* b) {
  30. int msg_size = 0;
  31. b->Args({0, 0}); // spl case: 0 ping-pong msgs (msg_size doesn't matter here)
  32. for (msg_size = 0; msg_size <= 128 * 1024 * 1024;
  33. msg_size == 0 ? msg_size++ : msg_size *= 8) {
  34. b->Args({msg_size, 1});
  35. b->Args({msg_size, 2});
  36. }
  37. }
  38. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator,
  39. NoOpMutator)
  40. ->Apply(StreamingPingPongArgs);
  41. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, MinInProcess, NoOpMutator,
  42. NoOpMutator)
  43. ->Apply(StreamingPingPongArgs);
  44. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator,
  45. NoOpMutator)
  46. ->Apply(StreamingPingPongArgs);
  47. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, MinInProcessCHTTP2, NoOpMutator,
  48. NoOpMutator)
  49. ->Apply(StreamingPingPongArgs);
  50. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2,
  51. Client_AddMetadata<RandomBinaryMetadata<10>, 1>, NoOpMutator)
  52. ->Args({0, 0});
  53. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2,
  54. Client_AddMetadata<RandomBinaryMetadata<31>, 1>, NoOpMutator)
  55. ->Args({0, 0});
  56. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2,
  57. Client_AddMetadata<RandomBinaryMetadata<100>, 1>,
  58. NoOpMutator)
  59. ->Args({0, 0});
  60. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2,
  61. Client_AddMetadata<RandomBinaryMetadata<10>, 2>, NoOpMutator)
  62. ->Args({0, 0});
  63. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2,
  64. Client_AddMetadata<RandomBinaryMetadata<31>, 2>, NoOpMutator)
  65. ->Args({0, 0});
  66. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2,
  67. Client_AddMetadata<RandomBinaryMetadata<100>, 2>,
  68. NoOpMutator)
  69. ->Args({0, 0});
  70. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator,
  71. Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>)
  72. ->Args({0, 0});
  73. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator,
  74. Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>)
  75. ->Args({0, 0});
  76. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator,
  77. Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>)
  78. ->Args({0, 0});
  79. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2,
  80. Client_AddMetadata<RandomAsciiMetadata<10>, 1>, NoOpMutator)
  81. ->Args({0, 0});
  82. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2,
  83. Client_AddMetadata<RandomAsciiMetadata<31>, 1>, NoOpMutator)
  84. ->Args({0, 0});
  85. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2,
  86. Client_AddMetadata<RandomAsciiMetadata<100>, 1>, NoOpMutator)
  87. ->Args({0, 0});
  88. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator,
  89. Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>)
  90. ->Args({0, 0});
  91. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator,
  92. Server_AddInitialMetadata<RandomAsciiMetadata<31>, 1>)
  93. ->Args({0, 0});
  94. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator,
  95. Server_AddInitialMetadata<RandomAsciiMetadata<100>, 1>)
  96. ->Args({0, 0});
  97. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator,
  98. Server_AddInitialMetadata<RandomAsciiMetadata<10>, 100>)
  99. ->Args({0, 0});
  100. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess,
  101. Client_AddMetadata<RandomBinaryMetadata<10>, 1>, NoOpMutator)
  102. ->Args({0, 0});
  103. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess,
  104. Client_AddMetadata<RandomBinaryMetadata<31>, 1>, NoOpMutator)
  105. ->Args({0, 0});
  106. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess,
  107. Client_AddMetadata<RandomBinaryMetadata<100>, 1>,
  108. NoOpMutator)
  109. ->Args({0, 0});
  110. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess,
  111. Client_AddMetadata<RandomBinaryMetadata<10>, 2>, NoOpMutator)
  112. ->Args({0, 0});
  113. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess,
  114. Client_AddMetadata<RandomBinaryMetadata<31>, 2>, NoOpMutator)
  115. ->Args({0, 0});
  116. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess,
  117. Client_AddMetadata<RandomBinaryMetadata<100>, 2>,
  118. NoOpMutator)
  119. ->Args({0, 0});
  120. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator,
  121. Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>)
  122. ->Args({0, 0});
  123. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator,
  124. Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>)
  125. ->Args({0, 0});
  126. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator,
  127. Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>)
  128. ->Args({0, 0});
  129. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess,
  130. Client_AddMetadata<RandomAsciiMetadata<10>, 1>, NoOpMutator)
  131. ->Args({0, 0});
  132. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess,
  133. Client_AddMetadata<RandomAsciiMetadata<31>, 1>, NoOpMutator)
  134. ->Args({0, 0});
  135. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess,
  136. Client_AddMetadata<RandomAsciiMetadata<100>, 1>, NoOpMutator)
  137. ->Args({0, 0});
  138. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator,
  139. Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>)
  140. ->Args({0, 0});
  141. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator,
  142. Server_AddInitialMetadata<RandomAsciiMetadata<31>, 1>)
  143. ->Args({0, 0});
  144. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator,
  145. Server_AddInitialMetadata<RandomAsciiMetadata<100>, 1>)
  146. ->Args({0, 0});
  147. BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator,
  148. Server_AddInitialMetadata<RandomAsciiMetadata<10>, 100>)
  149. ->Args({0, 0});
  150. } // namespace testing
  151. } // namespace grpc
  152. // Some distros have RunSpecifiedBenchmarks under the benchmark namespace,
  153. // and others do not. This allows us to support both modes.
  154. namespace benchmark {
  155. void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); }
  156. } // namespace benchmark
  157. int main(int argc, char** argv) {
  158. ::benchmark::Initialize(&argc, argv);
  159. ::grpc::testing::InitTest(&argc, &argv, false);
  160. benchmark::RunTheBenchmarksNamespaced();
  161. return 0;
  162. }