From 0df44cd0ac8363c6b046aa26316d8e3b19bcfeab Mon Sep 17 00:00:00 2001 From: Tobias Langer Date: Mon, 14 Nov 2016 18:03:17 +0100 Subject: [PATCH] Active waiting instead of sleeping. --- templates/normal/experiment.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/templates/normal/experiment.cpp b/templates/normal/experiment.cpp index 0bc763b..def027d 100644 --- a/templates/normal/experiment.cpp +++ b/templates/normal/experiment.cpp @@ -29,6 +29,13 @@ auto loop_count(int duration) -> long long return m * (float) duration + t; } +auto active_wait(int duration) -> void +{ + for(int i = 0; i < loop_count(duration); i++) { + donotoptimize(); + } +} + auto gcd(long long a, long long b) -> long long { return b == 0 ? a : gcd(b, a % b); @@ -126,9 +133,7 @@ static void IdleTask(const void* args, mtapi_size_t, void*, mtapi_size_t, /* idle until task completion. */ auto idle_time = taskset[task_id].wcet; - for(int i = 0; i < loop_count(idle_time); i++) { - donotoptimize(); - } + active_wait(idle_time); /* Store our benchmarking data. */ auto end_time = base_clock::now(); @@ -214,7 +219,7 @@ static void TaskStarter() } } - std::this_thread::sleep_for(min); + active_wait(min.count()); cur_time = duration_cast(base_clock::now() - start); } -- libgit2 0.26.0