Skip to content

Commit 1f12ec2

Browse files
authored
Switch to tbb::tick_count time measurement for TBB tasks (#737)
1 parent 05a4f9d commit 1f12ec2

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

modules/util/include/perf_test_util.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <gtest/gtest.h>
44
#include <omp.h>
5+
#include <tbb/tick_count.h>
56

67
#include <chrono>
78
#include <csignal>
@@ -54,14 +55,16 @@ class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, O
5455
const double t0 = omp_get_wtime();
5556
perf_attrs.current_timer = [t0] { return omp_get_wtime() - t0; };
5657
} else if (task_->GetDynamicTypeOfTask() == ppc::task::TypeOfTask::kSEQ ||
57-
task_->GetDynamicTypeOfTask() == ppc::task::TypeOfTask::kSTL ||
58-
task_->GetDynamicTypeOfTask() == ppc::task::TypeOfTask::kTBB) {
58+
task_->GetDynamicTypeOfTask() == ppc::task::TypeOfTask::kSTL) {
5959
const auto t0 = std::chrono::high_resolution_clock::now();
60-
perf_attrs.current_timer = [&] {
60+
perf_attrs.current_timer = [t0] {
6161
auto now = std::chrono::high_resolution_clock::now();
6262
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(now - t0).count();
6363
return static_cast<double>(ns) * 1e-9;
6464
};
65+
} else if (task_->GetDynamicTypeOfTask() == ppc::task::TypeOfTask::kTBB) {
66+
const auto t0 = tbb::tick_count::now();
67+
perf_attrs.current_timer = [t0] { return (tbb::tick_count::now() - t0).seconds(); };
6568
} else {
6669
throw std::runtime_error("The task type is not supported for performance testing.");
6770
}

0 commit comments

Comments
 (0)