bm_alarm.cc
Go to the documentation of this file.
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 
19 /* This benchmark exists to ensure that immediately-firing alarms are fast */
20 
21 #include <benchmark/benchmark.h>
22 
23 #include <grpc/grpc.h>
24 #include <grpcpp/alarm.h>
27 
31 
32 namespace grpc {
33 namespace testing {
34 
36  TrackCounters track_counters;
38  Alarm alarm;
39  void* output_tag;
40  bool ok;
41  auto deadline = grpc_timeout_seconds_to_deadline(0);
42  for (auto _ : state) {
43  alarm.Set(&cq, deadline, nullptr);
44  cq.Next(&output_tag, &ok);
45  }
46  track_counters.Finish(state);
47 }
49 
50 } // namespace testing
51 } // namespace grpc
52 
53 // Some distros have RunSpecifiedBenchmarks under the benchmark namespace,
54 // and others do not. This allows us to support both modes.
55 namespace benchmark {
57 } // namespace benchmark
58 
59 int main(int argc, char** argv) {
61  LibraryInitializer libInit;
62  ::benchmark::Initialize(&argc, argv);
63  grpc::testing::InitTest(&argc, &argv, false);
65  return 0;
66 }
grpc::testing::InitTest
void InitTest(int *argc, char ***argv, bool remove_flags)
Definition: test_config_cc.cc:28
testing
Definition: aws_request_signer_test.cc:25
grpc_timeout_seconds_to_deadline
gpr_timespec grpc_timeout_seconds_to_deadline(int64_t time_s)
Definition: test/core/util/test_config.cc:81
main
int main(int argc, char **argv)
Definition: bm_alarm.cc:59
benchmark
Definition: bm_alarm.cc:55
generate.env
env
Definition: generate.py:37
grpc
Definition: grpcpp/alarm.h:33
benchmark::RunTheBenchmarksNamespaced
void RunTheBenchmarksNamespaced()
Definition: bm_alarm.cc:56
TrackCounters::Finish
virtual void Finish(benchmark::State &state)
Definition: helpers.cc:44
alarm.h
TrackCounters
Definition: helpers.h:51
benchmark::RunSpecifiedBenchmarks
size_t RunSpecifiedBenchmarks()
Definition: benchmark/src/benchmark.cc:437
grpc::Alarm::Set
void Set(grpc::CompletionQueue *cq, const T &deadline, void *tag)
Definition: grpcpp/alarm.h:64
grpc.h
gmock_output_test._
_
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
completion_queue.h
benchmark::Initialize
void Initialize(int *argc, char **argv)
Definition: benchmark/src/benchmark.cc:602
helpers.h
LibraryInitializer
Definition: helpers.h:33
test_config.h
grpc_library.h
grpc::testing::BENCHMARK
static const int BENCHMARK
Definition: inproc_sync_unary_ping_pong_test.cc:35
grpc::testing::BM_Alarm_Tag_Immediate
static void BM_Alarm_Tag_Immediate(benchmark::State &state)
Definition: bm_alarm.cc:35
benchmark::State
Definition: benchmark/include/benchmark/benchmark.h:503
grpc::testing::TestEnvironment
Definition: test/core/util/test_config.h:54
ok
bool ok
Definition: async_end2end_test.cc:197
state
Definition: bloaty/third_party/zlib/contrib/blast/blast.c:41
test_config.h
grpc::CompletionQueue
Definition: include/grpcpp/impl/codegen/completion_queue.h:104
grpc::Alarm
Definition: grpcpp/alarm.h:35
cq
static grpc_completion_queue * cq
Definition: test/core/fling/client.cc:37


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