diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-04-23 21:32:56 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-04-23 21:33:29 +0300 |
commit | 36dd94ea93b742c949c6797ce09022df0b356029 (patch) | |
tree | 59cd5b5e399a33eb23b850c18a894c227d2f6125 /src | |
parent | a48c9dc049e5c22a18f4ca16c0aedddc94812436 (diff) | |
download | manaverse-36dd94ea93b742c949c6797ce09022df0b356029.tar.gz manaverse-36dd94ea93b742c949c6797ce09022df0b356029.tar.bz2 manaverse-36dd94ea93b742c949c6797ce09022df0b356029.tar.xz manaverse-36dd94ea93b742c949c6797ce09022df0b356029.zip |
Add test for dye speed.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/testlauncher.cpp | 33 | ||||
-rw-r--r-- | src/test/testlauncher.h | 5 |
2 files changed, 38 insertions, 0 deletions
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<int>(static_cast<long>(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 61ba168b8..25406aa14 100644 --- a/src/test/testlauncher.h +++ b/src/test/testlauncher.h @@ -70,6 +70,11 @@ class TestLauncher final int testDraw(); + int testDyeSpeed(); + + float calcTime(const timeval *const start, + const timeval *const end) const; + private: std::string mTest; |