Execute one thread of benchmark b for the specified number of iterations. Adds the stats collected for the thread into manager->results.
| 116 | // Execute one thread of benchmark b for the specified number of iterations. |
| 117 | // Adds the stats collected for the thread into manager->results. |
| 118 | void RunInThread(const BenchmarkInstance* b, IterationCount iters, |
| 119 | int thread_id, ThreadManager* manager, |
| 120 | PerfCountersMeasurement* perf_counters_measurement) { |
| 121 | internal::ThreadTimer timer( |
| 122 | b->measure_process_cpu_time() |
| 123 | ? internal::ThreadTimer::CreateProcessCpuTime() |
| 124 | : internal::ThreadTimer::Create()); |
| 125 | |
| 126 | State st = |
| 127 | b->Run(iters, thread_id, &timer, manager, perf_counters_measurement); |
| 128 | BM_CHECK(st.error_occurred() || st.iterations() >= st.max_iterations) |
| 129 | << "Benchmark returned before State::KeepRunning() returned false!"; |
| 130 | { |
| 131 | MutexLock l(manager->GetBenchmarkMutex()); |
| 132 | internal::ThreadManager::Result& results = manager->results; |
| 133 | results.iterations += st.iterations(); |
| 134 | results.cpu_time_used += timer.cpu_time_used(); |
| 135 | results.real_time_used += timer.real_time_used(); |
| 136 | results.manual_time_used += timer.manual_time_used(); |
| 137 | results.complexity_n += st.complexity_length_n(); |
| 138 | internal::Increment(&results.counters, st.counters); |
| 139 | } |
| 140 | manager->NotifyThreadComplete(); |
| 141 | } |
| 142 | |
| 143 | } // end namespace |
| 144 |
no test coverage detected