| 354 | } |
| 355 | |
| 356 | void runBenchmark() |
| 357 | { |
| 358 | pcg64 generator(randomSeed()); |
| 359 | std::uniform_int_distribution<size_t> distribution(0, queries.size() - 1); |
| 360 | |
| 361 | try |
| 362 | { |
| 363 | for (size_t i = 0; i < concurrency; ++i) |
| 364 | { |
| 365 | EntryPtrs connection_entries; |
| 366 | connection_entries.reserve(connections.size()); |
| 367 | |
| 368 | for (const auto & connection : connections) |
| 369 | connection_entries.emplace_back(std::make_shared<Entry>( |
| 370 | connection->get(ConnectionTimeouts::getTCPTimeoutsWithoutFailover(settings)))); |
| 371 | |
| 372 | pool.scheduleOrThrowOnError([this, connection_entries]() mutable { thread(connection_entries); }); |
| 373 | } |
| 374 | } |
| 375 | catch (...) |
| 376 | { |
| 377 | pool.wait(); |
| 378 | throw; |
| 379 | } |
| 380 | |
| 381 | InterruptListener interrupt_listener; |
| 382 | delay_watch.restart(); |
| 383 | |
| 384 | /// Push queries into queue |
| 385 | for (size_t i = 0; !max_iterations || i < max_iterations; ++i) |
| 386 | { |
| 387 | size_t query_index = randomize ? distribution(generator) : i % queries.size(); |
| 388 | |
| 389 | if (!tryPushQueryInteractively(queries[query_index], interrupt_listener)) |
| 390 | { |
| 391 | shutdown = true; |
| 392 | break; |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | pool.wait(); |
| 397 | total_watch.stop(); |
| 398 | |
| 399 | if (!json_path.empty()) |
| 400 | reportJSON(comparison_info_total, json_path); |
| 401 | |
| 402 | printNumberOfQueriesExecuted(queries_executed); |
| 403 | report(comparison_info_total); |
| 404 | } |
| 405 | |
| 406 | |
| 407 | void thread(EntryPtrs & connection_entries) |
nothing calls this directly
no test coverage detected