MCPcopy Create free account
hub / github.com/apache/qpid-proton / BM_EncodeMapMessage

Function BM_EncodeMapMessage

c/benchmarks/message-encoding_map.cpp:67–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67static void BM_EncodeMapMessage(benchmark::State &state) {
68 if (VERBOSE)
69 printf("BEGIN BM_EncodeMapMessage\n");
70
71 uint64_t entries = 0;
72
73 pn_message_t *message = pn_message();
74
75 for (auto _ : state) {
76 pn_message_clear(message);
77 pn_data_t *body;
78 body = pn_message_body(message);
79 pn_data_put_map(body);
80 pn_data_enter(body);
81 for (size_t i = 0; i < state.range(0); ++i) {
82 pn_data_put_int(body, i);
83 pn_data_put_string(
84 body, pn_bytes(sizeof("some key value") - 1, "some key value"));
85 entries += 2;
86 }
87 pn_data_exit(body);
88 pn_rwbytes_t buf{};
89 if (pn_message_encode2(message, &buf) == 0) {
90 state.SkipWithError(pn_error_text(pn_message_error(message)));
91 }
92 if (buf.start)
93 free(buf.start);
94 }
95 pn_message_free(message);
96
97 state.SetLabel("entries");
98 state.SetItemsProcessed(entries);
99
100 if (VERBOSE)
101 printf("END BM_EncodeMapMessage\n");
102}
103
104BENCHMARK(BM_EncodeMapMessage)
105 ->Arg(10)

Callers

nothing calls this directly

Calls 13

pn_messageFunction · 0.85
pn_message_clearFunction · 0.85
pn_message_bodyFunction · 0.85
pn_data_put_mapFunction · 0.85
pn_data_enterFunction · 0.85
pn_data_put_intFunction · 0.85
pn_data_exitFunction · 0.85
pn_message_encode2Function · 0.85
pn_message_errorFunction · 0.85
pn_message_freeFunction · 0.85
pn_data_put_stringFunction · 0.50
pn_bytesFunction · 0.50

Tested by

no test coverage detected