summaryrefslogtreecommitdiff
path: root/src/test/testlauncher.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-04-23 21:32:56 +0300
committerAndrei Karas <akaras@inbox.ru>2015-04-23 21:33:29 +0300
commit36dd94ea93b742c949c6797ce09022df0b356029 (patch)
tree59cd5b5e399a33eb23b850c18a894c227d2f6125 /src/test/testlauncher.cpp
parenta48c9dc049e5c22a18f4ca16c0aedddc94812436 (diff)
downloadplus-36dd94ea93b742c949c6797ce09022df0b356029.tar.gz
plus-36dd94ea93b742c949c6797ce09022df0b356029.tar.bz2
plus-36dd94ea93b742c949c6797ce09022df0b356029.tar.xz
plus-36dd94ea93b742c949c6797ce09022df0b356029.zip
Add test for dye speed.
Diffstat (limited to 'src/test/testlauncher.cpp')
-rw-r--r--src/test/testlauncher.cpp33
1 files changed, 33 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