| 152 | } |
| 153 | |
| 154 | void BenchMark::Run() |
| 155 | { |
| 156 | printf("qps: %d\n", impl_->qps); |
| 157 | printf("nthread: %d\n", impl_->nthread); |
| 158 | printf("nroutine: %d\n", impl_->nroutine); |
| 159 | printf("routine_sleep_time(ms): %d\n", impl_->routine_sleep_time_ms); |
| 160 | printf("start run...\n"); |
| 161 | |
| 162 | impl_->stats.reset(new StatData[impl_->nthread]); |
| 163 | |
| 164 | for (int i{0}; i < impl_->nthread; ++i) { |
| 165 | pthread_t tid; |
| 166 | pthread_create(&tid, 0, ThreadRunFunc, new ThreadRunFuncArgs_t{i, this}); |
| 167 | pthread_detach(tid); |
| 168 | } |
| 169 | |
| 170 | // stat |
| 171 | gettimeofday(&impl_->last_stat_time, nullptr); |
| 172 | while (true) { |
| 173 | std::this_thread::sleep_for(std::chrono::seconds(10)); |
| 174 | ResStat(); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | int BenchMark::GetRoutineSleepTimeMS() { |
| 179 | return impl_->routine_sleep_time_ms; |
nothing calls this directly
no outgoing calls
no test coverage detected