sends single message and closes the connection
| 121 | |
| 122 | // sends single message and closes the connection |
| 123 | static 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 | |
| 178 | BENCHMARK(BM_EstablishConnection)->Unit(benchmark::kMicrosecond); |
| 179 |
nothing calls this directly
no test coverage detected