From 4e6c08b939fbfb1cd4a8a5653bd16d285b55150c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 24 Apr 2015 02:10:19 +0300 Subject: Update test for dye speed. --- src/test/testlauncher.cpp | 25 ++++++++++--------------- src/test/testlauncher.h | 3 --- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index 7b47963b2..74447af7e 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -460,22 +460,25 @@ int TestLauncher::testDye() int TestLauncher::testDyeSpeed() { - timeval start; - timeval end; - const int sz = 10000; + const int sz = 100000; uint32_t buf[sz]; + timespec time1; + timespec time2; DyePalette pal("#0000ff,000000,000020,706050", 6); for (int f = 0; f < sz; f ++) buf[f] = f; - gettimeofday(&start, nullptr); + clock_gettime(CLOCK_MONOTONIC, &time1); - pal.replaceSColor(buf, sz); + for (int f = 0; f < 1000; f ++) + pal.replaceSColor(buf, sz); - gettimeofday(&end, nullptr); - printf("time: %f\n", calcTime(&start, &end)); + clock_gettime(CLOCK_MONOTONIC, &time2); + long diff = ((static_cast(time2.tv_sec) * 1000000000LL + static_cast(time2.tv_nsec)) / 1) - + ((static_cast(time1.tv_sec) * 1000000000LL + static_cast(time1.tv_nsec)) / 1); + printf("time: %ld\n", diff); return 0; } @@ -576,12 +579,4 @@ int TestLauncher::calcFps(const timeval *const start, const timeval *const end, return static_cast(static_cast(calls) * 10000 / mtime); } -float TestLauncher::calcTime(const timeval *const start, - const timeval *const end) const -{ - const long seconds = end->tv_sec - start->tv_sec; - const long useconds = end->tv_usec - start->tv_usec; - - return (seconds * 1000 + useconds / 1000.0); -} #endif diff --git a/src/test/testlauncher.h b/src/test/testlauncher.h index 25406aa14..abb84483b 100644 --- a/src/test/testlauncher.h +++ b/src/test/testlauncher.h @@ -72,9 +72,6 @@ class TestLauncher final int testDyeSpeed(); - float calcTime(const timeval *const start, - const timeval *const end) const; - private: std::string mTest; -- cgit v1.2.3-60-g2f50