From cecfeed61e8bcb4b53c2ed8e1b26d8c8af38b8e3 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 14 Sep 2019 03:40:47 +0300 Subject: libcamera: Switch to the std::chrono API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the clock_gettime()-based API with durations expressed as integers with the std::chrono API. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- test/event-dispatcher.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'test/event-dispatcher.cpp') diff --git a/test/event-dispatcher.cpp b/test/event-dispatcher.cpp index f243ec39..9f9cf178 100644 --- a/test/event-dispatcher.cpp +++ b/test/event-dispatcher.cpp @@ -5,6 +5,7 @@ * event-dispatcher.cpp - Event dispatcher test */ +#include #include #include #include @@ -47,8 +48,7 @@ protected: Timer timer; /* Event processing interruption by signal. */ - struct timespec start; - clock_gettime(CLOCK_MONOTONIC, &start); + std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); timer.start(1000); @@ -59,12 +59,11 @@ protected: dispatcher->processEvents(); - struct timespec stop; - clock_gettime(CLOCK_MONOTONIC, &stop); - int duration = (stop.tv_sec - start.tv_sec) * 1000; - duration += (stop.tv_nsec - start.tv_nsec) / 1000000; + std::chrono::steady_clock::time_point stop = std::chrono::steady_clock::now(); + std::chrono::steady_clock::duration duration = stop - start; + int msecs = std::chrono::duration_cast(duration).count(); - if (abs(duration - 1000) > 50) { + if (abs(msecs - 1000) > 50) { cout << "Event processing restart test failed" << endl; return TestFail; } -- cgit v1.2.1