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

Function BM_EstablishConnection

c/benchmarks/connection-driver.cpp:123–176  ·  view source on GitHub ↗

sends single message and closes the connection

Source from the content-addressed store, hash-verified

121
122// sends single message and closes the connection
123static void BM_EstablishConnection(benchmark::State &state) {
124 if (VERBOSE)
125 printf("BEGIN BM_EstablishConnection\n");
126
127 for (auto _ : state) {
128 app_data_t app = {};
129 app.message_count = 1;
130 app.message = pn_message();
131 sprintf(app.container_id, "%s:%06x", "BM_EstablishConnection",
132 rand() & 0xffffff);
133
134 pn_connection_driver_t receiver;
135 if (pn_connection_driver_init(&receiver, NULL, NULL) != 0) {
136 printf("receiver: pn_connection_driver_init failed\n");
137 exit(1);
138 }
139
140 pn_connection_driver_t sender;
141 if (pn_connection_driver_init(&sender, NULL, NULL) != 0) {
142 printf("sender: pn_connection_driver_init failed\n");
143 exit(1);
144 }
145
146 do {
147 pn_event_t *event;
148 while ((event = pn_connection_driver_next_event(&sender)) != NULL) {
149 handle_sender(&app, event);
150 }
151 shovel(sender, receiver);
152 while ((event = pn_connection_driver_next_event(&receiver)) != NULL) {
153 handle_receiver(&app, event);
154 }
155 shovel(receiver, sender);
156 } while (app.closed < 2); // until both sender and receiver are closed
157
158 pn_message_free(app.message);
159
160 pn_connection_driver_close(&receiver);
161 pn_connection_driver_close(&sender);
162
163 shovel(receiver, sender);
164 shovel(sender, receiver);
165
166 // this can take long time, up to 500 ms
167 pn_connection_driver_destroy(&receiver);
168 pn_connection_driver_destroy(&sender);
169 }
170
171 state.SetLabel("connections");
172 state.SetItemsProcessed(state.iterations());
173
174 if (VERBOSE)
175 printf("END BM_EstablishConnection\n");
176}
177
178BENCHMARK(BM_EstablishConnection)->Unit(benchmark::kMicrosecond);
179

Callers

nothing calls this directly

Calls 11

pn_messageFunction · 0.85
exitFunction · 0.85
handle_senderFunction · 0.85
shovelFunction · 0.85
handle_receiverFunction · 0.85
pn_message_freeFunction · 0.85
iterationsMethod · 0.80

Tested by

no test coverage detected