qps_openloop_test.cc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. *
  3. * Copyright 2015 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 <set>
  19. #include <grpc/support/log.h>
  20. #include "test/core/util/test_config.h"
  21. #include "test/cpp/qps/benchmark_config.h"
  22. #include "test/cpp/qps/driver.h"
  23. #include "test/cpp/qps/report.h"
  24. #include "test/cpp/qps/server.h"
  25. #include "test/cpp/util/test_config.h"
  26. #include "test/cpp/util/test_credentials_provider.h"
  27. namespace grpc {
  28. namespace testing {
  29. static const int WARMUP = 1;
  30. static const int BENCHMARK = 3;
  31. static void RunQPS() {
  32. gpr_log(GPR_INFO, "Running QPS test, open-loop");
  33. ClientConfig client_config;
  34. client_config.set_client_type(ASYNC_CLIENT);
  35. client_config.set_outstanding_rpcs_per_channel(100);
  36. client_config.set_client_channels(8);
  37. client_config.set_async_client_threads(8);
  38. client_config.set_rpc_type(STREAMING);
  39. client_config.mutable_load_params()->mutable_poisson()->set_offered_load(
  40. 1000.0 / grpc_test_slowdown_factor());
  41. ServerConfig server_config;
  42. server_config.set_server_type(ASYNC_SERVER);
  43. server_config.set_async_server_threads(8);
  44. const auto result =
  45. RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2, "",
  46. kInsecureCredentialsType, {}, false, 0);
  47. GetReporter()->ReportQPSPerCore(*result);
  48. GetReporter()->ReportLatency(*result);
  49. }
  50. } // namespace testing
  51. } // namespace grpc
  52. int main(int argc, char** argv) {
  53. grpc::testing::TestEnvironment env(argc, argv);
  54. grpc::testing::InitTest(&argc, &argv, true);
  55. grpc::testing::RunQPS();
  56. return 0;
  57. }