helpers.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2017 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 #ifndef TEST_CPP_MICROBENCHMARKS_COUNTERS_H
20 #define TEST_CPP_MICROBENCHMARKS_COUNTERS_H
21 
23 
24 #include <sstream>
25 #include <vector>
26 
27 #include <benchmark/benchmark.h>
28 
30 
32 
34  public:
37 
38  static LibraryInitializer& get();
39 
40  private:
42 };
43 
44 #ifdef GPR_LOW_LEVEL_COUNTERS
45 extern gpr_atm gpr_mu_locks;
46 extern gpr_atm gpr_counter_atm_cas;
47 extern gpr_atm gpr_counter_atm_add;
48 extern gpr_atm gpr_now_call_count;
49 #endif
50 
52  public:
54  virtual ~TrackCounters() {}
55  virtual void Finish(benchmark::State& state);
56  virtual void AddLabel(const std::string& label);
57  virtual void AddToLabel(std::ostream& out, benchmark::State& state);
58 
59  private:
61  std::vector<std::string> labels_;
62 #ifdef GPR_LOW_LEVEL_COUNTERS
63  const size_t mu_locks_at_start_ = gpr_atm_no_barrier_load(&gpr_mu_locks);
64  const size_t atm_cas_at_start_ =
65  gpr_atm_no_barrier_load(&gpr_counter_atm_cas);
66  const size_t atm_add_at_start_ =
67  gpr_atm_no_barrier_load(&gpr_counter_atm_add);
68  const size_t now_calls_at_start_ =
69  gpr_atm_no_barrier_load(&gpr_now_call_count);
70 #endif
71 };
72 
73 #endif
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
gpr_atm_no_barrier_load
#define gpr_atm_no_barrier_load(p)
Definition: impl/codegen/atm_gcc_atomic.h:53
TrackCounters::TrackCounters
TrackCounters()
Definition: helpers.h:53
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
TrackCounters::Finish
virtual void Finish(benchmark::State &state)
Definition: helpers.cc:44
stats.h
TrackCounters::labels_
std::vector< std::string > labels_
Definition: helpers.h:61
TrackCounters
Definition: helpers.h:51
gen_synthetic_protos.label
label
Definition: gen_synthetic_protos.py:102
LibraryInitializer::~LibraryInitializer
~LibraryInitializer()
Definition: helpers.cc:34
TrackCounters::stats_begin_
grpc_stats_data stats_begin_
Definition: helpers.h:60
grpc_stats_collect
void grpc_stats_collect(grpc_stats_data *output)
Definition: stats.cc:48
grpc::internal::GrpcLibrary
Definition: grpcpp/impl/grpc_library.h:32
TrackCounters::~TrackCounters
virtual ~TrackCounters()
Definition: helpers.h:54
LibraryInitializer::LibraryInitializer
LibraryInitializer()
Definition: helpers.cc:26
LibraryInitializer
Definition: helpers.h:33
gpr_atm
intptr_t gpr_atm
Definition: impl/codegen/atm_gcc_atomic.h:32
TrackCounters::AddLabel
virtual void AddLabel(const std::string &label)
Definition: helpers.cc:57
grpc_library.h
benchmark::State
Definition: benchmark/include/benchmark/benchmark.h:503
grpc_stats_data
Definition: src/core/lib/debug/stats.h:33
state
Definition: bloaty/third_party/zlib/contrib/blast/blast.c:41
LibraryInitializer::init_lib_
grpc::internal::GrpcLibrary init_lib_
Definition: helpers.h:41
LibraryInitializer::get
static LibraryInitializer & get()
Definition: helpers.cc:39
TrackCounters::AddToLabel
virtual void AddToLabel(std::ostream &out, benchmark::State &state)
Definition: helpers.cc:61
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:12