Go to the documentation of this file.
26 #include <benchmark/benchmark.h>
51 #include "src/proto/grpc/testing/echo.grpc.pb.h"
64 size_t sz =
state.range(0);
117 template <
class Fixture>
141 return reinterpret_cast<void*
>(
static_cast<intptr_t>(
i));
151 std::vector<std::unique_ptr<
155 grpc::testing::EchoResponse recv_response;
161 reader->Finish(&recv_response, &recv_status,
tag(0));
191 channel,
"/grpc.testing.EchoTestService/Echo",
nullptr,
nullptr);
265 channel,
"/grpc.testing.EchoTestService/Echo",
nullptr,
nullptr);
290 (
void*)
nullptr,
nullptr));
348 a.key =
const_cast<char*
>(
key);
349 a.value.string =
const_cast<char*
>(
value);
358 template <const grpc_channel_filter* kFilter, u
int32_t kFlags>
465 [](
void* p) {
return p; },
491 grpc_schedule_on_exec_ctx);
500 p->op_payload_.send_initial_metadata.send_initial_metadata = &
batch_;
520 template <
class Fixture,
class TestOp>
524 std::ostringstream
label;
527 std::vector<grpc_arg>
args = {
529 &fake_client_channel_factory),
537 std::vector<const grpc_channel_filter*> filters;
538 if (
fixture.filter !=
nullptr) {
539 filters.push_back(
fixture.filter);
543 label <<
" #has_phony_filter";
548 filters.empty() ?
nullptr : &filters[0], filters.size());
552 "channel_stack_init",
554 filters.empty() ?
nullptr : &filters[0],
555 filters.size(), &channel_args,
"CHANNEL",
561 gpr_cycle_counter
start_time = gpr_get_cycle_counter();
565 const int kArenaSize = 32 * 1024 * 1024;
576 while (
state.KeepRunning()) {
580 typename TestOp::Op
op(&test_op_data, call_stack, call_args.arena);
585 if (0 == (
state.iterations() & 0xffff)) {
586 call_args.arena->Destroy();
591 call_args.arena->Destroy();
655 if (
op->recv_initial_metadata) {
656 closures.
Add(
op->payload->recv_initial_metadata.recv_initial_metadata_ready,
659 if (
op->recv_message) {
663 if (
op->recv_trailing_metadata) {
665 op->payload->recv_trailing_metadata.recv_trailing_metadata_ready,
668 if (
op->on_complete !=
nullptr) {
716 "isolated_call_filter"};
732 builder.SetTarget(
"phony_target");
766 method_hdl, deadline,
nullptr));
794 &recv_initial_metadata;
805 method_hdl, deadline,
nullptr);
834 &recv_initial_metadata;
837 method_hdl, deadline,
nullptr);
864 int main(
int argc,
char** argv) {
#define GRPC_CLOSURE_INIT(closure, cb, cb_arg, scheduler)
void InitTest(int *argc, char ***argv, bool remove_flags)
GPRAPI void grpc_slice_unref(grpc_slice s)
std::shared_ptr< Channel > CreateChannelInternal(const std::string &host, grpc_channel *c_channel, std::vector< std::unique_ptr< experimental::ClientInterceptorFactoryInterface >> interceptor_creators)
struct grpc_byte_buffer * send_message
void DestroyStream(grpc_transport *, grpc_stream *, grpc_closure *)
void PerformOp(grpc_transport *, grpc_transport_op *)
static const grpc_transport_vtable vtable
grpc_metadata_array * trailing_metadata
static Arena * Create(size_t initial_size, MemoryAllocator *memory_allocator)
void SetPollset(grpc_transport *, grpc_stream *, grpc_pollset *)
grpc_status_code * status
GRPCAPI grpc_byte_buffer * grpc_raw_byte_buffer_create(grpc_slice *slices, size_t nslices)
static const grpc_channel_filter kFilter
@ GRPC_STATUS_UNAUTHENTICATED
return memset(p, 0, total)
void Finish(benchmark::State &state) override
void DestroyChannelElem(grpc_channel_element *)
static grpc_channel * CreateChannel()
Fixture< nullptr, 0 > NoFilter
struct connected_channel_call_data call_data
struct grpc_op::grpc_op_data::grpc_op_send_initial_metadata send_initial_metadata
static void BM_IsolatedCall_Unary(benchmark::State &state)
static void DestroyCallElem(grpc_call_element *, const grpc_call_final_info *, grpc_closure *)
#define GPR_TIMER_SCOPE(tag, important)
static void SetPollsetOrPollsetSet(grpc_call_element *, grpc_polling_entity *)
grpc_closure * on_complete
GPRAPI grpc_slice grpc_slice_new(void *p, size_t len, void(*destroy)(void *))
struct grpc_pollset_set grpc_pollset_set
GRPCAPI grpc_channel * grpc_lame_client_channel_create(const char *target, grpc_status_code error_code, const char *error_message)
static void SetPollsetOrPollsetSet(grpc_call_element *, grpc_polling_entity *)
GPRAPI void gpr_free(void *ptr)
static grpc_error_handle InitCallElem(grpc_call_element *elem, const grpc_call_element_args *args)
static const grpc_transport_vtable phony_transport_vtable
static void BM_IsolatedFilter(benchmark::State &state)
static auto * g_memory_allocator
void GetChannelInfo(grpc_channel_element *, const grpc_channel_info *)
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
grpc_error_handle InitChannelElem(grpc_channel_element *, grpc_channel_element_args *)
void RunTheBenchmarksNamespaced()
grpc_error_handle grpc_call_stack_init(grpc_channel_stack *channel_stack, int initial_refs, grpc_iomgr_cb_func destroy, void *destroy_arg, const grpc_call_element_args *elem_args)
#define GRPC_LOG_IF_ERROR(what, error)
static int64_t start_time
virtual void Finish(benchmark::State &state)
void grpc_channel_stack_destroy(grpc_channel_stack *stack)
Fixture<&grpc_core::HttpServerFilter::kFilter, CHECKS_NOT_LAST > HttpServerFilter
Fixture<&grpc_server_deadline_filter, CHECKS_NOT_LAST > ServerDeadlineFilter
int InitStream(grpc_transport *, grpc_stream *, grpc_stream_refcount *, const void *, grpc_core::Arena *)
grpc_core::CallCombiner * call_combiner
int main(int argc, char **argv)
struct grpc_op::grpc_op_data::grpc_op_recv_message recv_message
grpc_core::ScopedArenaPtr arena
static grpc_error_handle InitCallElem(grpc_call_element *, const grpc_call_element_args *)
union grpc_op::grpc_op_data data
void PerformStreamOp(grpc_transport *, grpc_stream *, grpc_transport_stream_op_batch *op)
GPRAPI void * gpr_zalloc(size_t size)
GRPCAPI void * grpc_channel_register_call(grpc_channel *channel, const char *method, const char *host, void *reserved)
GRPCAPI void grpc_metadata_array_destroy(grpc_metadata_array *array)
struct grpc_byte_buffer ** recv_message
size_t RunSpecifiedBenchmarks()
static grpc_metadata_array trailing_metadata_recv
static const grpc_channel_filter phony_filter
wrapped_grpc_channel * channel
static void BM_IsolatedCall_NoOp(benchmark::State &state)
@ GRPC_OP_RECV_INITIAL_METADATA
grpc_core::RefCountedPtr< grpc_core::Subchannel > CreateSubchannel(const grpc_resolved_address &, const grpc_channel_args *) override
static const CoreConfiguration & Get()
static const char fixture[]
grpc_endpoint * GetEndpoint(grpc_transport *)
#define GRPC_ARG_SERVER_URI
void grpc_channel_stack_no_post_init(grpc_channel_stack *, grpc_channel_element *)
GRPCAPI void grpc_call_unref(grpc_call *call)
grpc_channel * channel() const
struct grpc_call grpc_call
static grpc_byte_buffer * response_payload_recv
static void StartTransportOp(grpc_channel_element *, grpc_transport_op *)
GRPCAPI grpc_channel_credentials * grpc_insecure_credentials_create()
static void StartTransportStreamOp(grpc_call_element *elem, grpc_transport_stream_op_batch *op)
BENCHMARK(BM_LameChannelCallCreateCpp)
GPRAPI grpc_slice grpc_slice_from_static_string(const char *source)
grpc_transport_stream_op_batch_payload * payload
void DestroyChannelElem(grpc_channel_element *)
GPRAPI grpc_slice grpc_empty_slice(void)
grpc_error_handle InitChannelElem(grpc_channel_element *, grpc_channel_element_args *)
void grpc_call_stack_destroy(grpc_call_stack *stack, const grpc_call_final_info *final_info, grpc_closure *then_schedule_closure)
static ResourceQuotaRefPtr Default()
void Initialize(int *argc, char **argv)
const grpc_channel_filter * filter
grpc_completion_queue * cq_
static grpc_arg CreateChannelArg(ClientChannelFactory *factory)
const ChannelArgsPreconditioning & channel_args_preconditioning() const
GPRAPI gpr_timespec gpr_now(gpr_clock_type clock)
void BM_Zalloc(benchmark::State &state)
grpc_slice * status_details
grpc_completion_queue * cq() const
grpc_channel * channel() const
Fixture<&grpc_client_deadline_filter, CHECKS_NOT_LAST > ClientDeadlineFilter
static grpc_slice details
void RunClosures(CallCombiner *call_combiner)
GRPCAPI grpc_call * grpc_channel_create_registered_call(grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_completion_queue *completion_queue, void *registered_call_handle, gpr_timespec deadline, void *reserved)
Fixture<&phony_filter::phony_filter, 0 > PhonyFilter
GRPCAPI void grpc_channel_credentials_release(grpc_channel_credentials *creds)
static void StartTransportOp(grpc_channel_element *, grpc_transport_op *op)
size_t grpc_channel_stack_size(const grpc_channel_filter **filters, size_t filter_count)
GRPCAPI grpc_channel * grpc_channel_create(const char *target, grpc_channel_credentials *creds, const grpc_channel_args *args)
static grpc_arg StringArg(const char *key, const char *value)
#define GRPC_PROPAGATE_DEFAULTS
void Destroy(grpc_transport *)
int QsortCompare(const T &a, const T &b)
void Add(grpc_closure *closure, grpc_error_handle error, const char *reason)
GRPCAPI void grpc_completion_queue_destroy(grpc_completion_queue *cq)
@ GRPC_OP_SEND_INITIAL_METADATA
grpc_core::ExecCtx exec_ctx
struct grpc_op::grpc_op_data::grpc_op_send_message send_message
void SetPollsetSet(grpc_transport *, grpc_stream *, grpc_pollset_set *)
BENCHMARK_TEMPLATE(BM_CallCreateDestroy, InsecureChannel)
Fixture<&grpc_core::HttpClientFilter::kFilter, CHECKS_NOT_LAST|REQUIRES_TRANSPORT > HttpClientFilter
struct grpc_op::grpc_op_data::grpc_op_recv_status_on_client recv_status_on_client
static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State &state)
grpc_error_handle grpc_channel_stack_init(int initial_refs, grpc_iomgr_cb_func destroy, void *destroy_arg, const grpc_channel_filter **filters, size_t filter_count, const grpc_channel_args *channel_args, const char *name, grpc_channel_stack *stack)
GRPCAPI void grpc_byte_buffer_destroy(grpc_byte_buffer *bb)
GRPCAPI grpc_event grpc_completion_queue_next(grpc_completion_queue *cq, gpr_timespec deadline, void *reserved)
Fixture<&grpc_message_compress_filter, CHECKS_NOT_LAST > CompressFilter
bool send_initial_metadata
GRPCAPI void grpc_channel_destroy(grpc_channel *channel)
Fixture<&grpc_core::ClientChannel::kFilterVtable, 0 > ClientChannelFilter
void GetChannelInfo(grpc_channel_element *, const grpc_channel_info *)
#define GRPC_ERROR_UNREF(err)
static void Run(const DebugLocation &location, grpc_closure *closure, grpc_error_handle error)
struct grpc_channel grpc_channel
static void DestroyCallElem(grpc_call_element *, const grpc_call_final_info *, grpc_closure *then_sched_closure)
struct grpc_stream grpc_stream
static const grpc_channel_filter isolated_call_filter
grpc::ClientContext context
BaseChannelFixture(grpc_channel *channel)
Fixture<&grpc_message_size_filter, CHECKS_NOT_LAST > MessageSizeFilter
static constexpr Timestamp InfFuture()
grpc_channel *const channel_
GRPCAPI grpc_completion_queue * grpc_completion_queue_create_for_next(void *reserved)
struct grpc_op::grpc_op_data::grpc_op_recv_initial_metadata recv_initial_metadata
static void do_nothing(void *)
static absl::StatusOr< RefCountedPtr< Channel > > CreateWithBuilder(ChannelStackBuilder *builder)
grpc_completion_type type
GRPCAPI void grpc_init(void)
static void BM_LameChannelCallCreateCore(benchmark::State &state)
@ GRPC_OP_RECV_STATUS_ON_CLIENT
static void FilterDestroy(void *arg, grpc_error_handle)
grpc_arg grpc_channel_arg_pointer_create(char *name, void *value, const grpc_arg_pointer_vtable *vtable)
static grpc_metadata_array initial_metadata_recv
static void BM_CallCreateDestroy(benchmark::State &state)
GRPCAPI grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops, size_t nops, void *tag, void *reserved)
static void BM_IsolatedCall_StreamingSend(benchmark::State &state)
ChannelArgs PreconditionChannelArgs(const grpc_channel_args *args) const
static grpc_completion_queue * cq
Op(NoOp *, grpc_call_stack *, grpc_core::Arena *)
@ GRPC_OP_SEND_CLOSE_FROM_CLIENT
static void StartTransportStreamOp(grpc_call_element *, grpc_transport_stream_op_batch *)
static void DoNothing(void *, grpc_error_handle)
GRPCAPI void grpc_metadata_array_init(grpc_metadata_array *array)
static void BM_LameChannelCallCreateCpp(benchmark::State &state)
#define GRPC_ERROR_IS_NONE(err)
#define GRPC_ARG_TRANSPORT
grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:48