From 36dd94ea93b742c949c6797ce09022df0b356029 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 23 Apr 2015 21:32:56 +0300 Subject: Add test for dye speed. --- src/test/testlauncher.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/test/testlauncher.cpp') diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index 7fd1a2382..7b47963b2 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -36,6 +36,7 @@ #include "utils/physfsrwops.h" #include "resources/dye.h" +#include "resources/dyepalette.h" #include "resources/image.h" #include "resources/imagewriter.h" #include "resources/openglimagehelper.h" @@ -94,6 +95,8 @@ int TestLauncher::exec() return testFps2(); else if (mTest == "104") return testFps3(); + else if (mTest == "105") + return testDyeSpeed(); return -1; } @@ -455,6 +458,27 @@ int TestLauncher::testDye() return 0; } +int TestLauncher::testDyeSpeed() +{ + timeval start; + timeval end; + const int sz = 10000; + uint32_t buf[sz]; + + DyePalette pal("#0000ff,000000,000020,706050", 6); + + for (int f = 0; f < sz; f ++) + buf[f] = f; + + gettimeofday(&start, nullptr); + + pal.replaceSColor(buf, sz); + + gettimeofday(&end, nullptr); + printf("time: %f\n", calcTime(&start, &end)); + return 0; +} + int TestLauncher::testDraw() { Image *img[3]; @@ -551,4 +575,13 @@ 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 -- cgit v1.2.3-70-g09d2