| 115 | } |
| 116 | |
| 117 | static void peekThread(const mz::Config* pConfig, const std::atomic<RunState> *pRunState, |
| 118 | std::promise<std::vector<Histogram>> promHist, useconds_t sleepMin, useconds_t sleepMax) { |
| 119 | const mz::Config& config = *pConfig; |
| 120 | const std::atomic<RunState>& runState = *pRunState; |
| 121 | pqxx::connection c(config.materializedUrl); |
| 122 | // FIXME |
| 123 | assert(!config.hQueries.empty()); |
| 124 | size_t iQuery = 0; |
| 125 | size_t size = config.hQueries.size(); |
| 126 | while (runState == RunState::warmup) { |
| 127 | const auto& q = config.hQueries[iQuery]; |
| 128 | mz::peekView(c, q->first, q->second.order, q->second.limit); |
| 129 | iQuery = (iQuery + 1) % size; |
| 130 | auto sleepTime = chRandom::uniformInt(sleepMin, sleepMax); |
| 131 | usleep(sleepTime); |
| 132 | } |
| 133 | std::vector<Histogram> hists; |
| 134 | hists.resize(size); |
| 135 | while (runState == RunState::run) { |
| 136 | const auto& q = config.hQueries[iQuery]; |
| 137 | auto latency = mz::peekView(c, q->first, q->second.order, q->second.limit).latency; |
| 138 | hists[iQuery].increment(latency.count()); |
| 139 | iQuery = (iQuery + 1) % size; |
| 140 | auto sleepTime = chRandom::uniformInt(sleepMin, sleepMax); |
| 141 | usleep(sleepTime); |
| 142 | } |
| 143 | promHist.set_value(std::move(hists)); |
| 144 | } |
| 145 | static void materializeThread(mz::Config config, std::promise<std::vector<Histogram>> promHist, |
| 146 | int peekConns, bool materializeSources, const std::atomic<RunState> *pRunState, |
| 147 | useconds_t peekMin, useconds_t peekMax) { |