Skip to content

Commit e577673

Browse files
committed
Skip first iteration in mt benchmarks
so that we do not measure warmup time
1 parent eb85278 commit e577673

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

benchmark/multithread.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ typename TimeUnit::rep measure(F &&func) {
101101
/* Measure time of execution of run_workload(thread_id) function. */
102102
template <typename TimeUnit, typename F>
103103
auto measure(size_t iterations, size_t concurrency, F &&run_workload) {
104+
if (iterations == 1) {
105+
throw std::runtime_error("iterations must be > 1");
106+
}
107+
104108
using ResultsType = typename TimeUnit::rep;
105109
std::vector<ResultsType> results;
106110

@@ -115,8 +119,12 @@ auto measure(size_t iterations, size_t concurrency, F &&run_workload) {
115119

116120
syncthreads();
117121
});
118-
results.insert(results.end(), iteration_results.begin(),
119-
iteration_results.end());
122+
123+
// skip the first 'warmup' iteration
124+
if (i != 0) {
125+
results.insert(results.end(), iteration_results.begin(),
126+
iteration_results.end());
127+
}
120128
}
121129

122130
return results;

0 commit comments

Comments
 (0)