summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-06-03 23:31:14 +0300
committerAndrei Karas <akaras@inbox.ru>2017-06-04 01:34:43 +0300
commit55694af091d01efc65c27df4ae7bbbe8444818da (patch)
treecc264d49be69681ef65c0515b5fc950c6ef0654a /src
parent8340a5b04420d2c456618245371cc6e268e5fa5d (diff)
downloadplus-55694af091d01efc65c27df4ae7bbbe8444818da.tar.gz
plus-55694af091d01efc65c27df4ae7bbbe8444818da.tar.bz2
plus-55694af091d01efc65c27df4ae7bbbe8444818da.tar.xz
plus-55694af091d01efc65c27df4ae7bbbe8444818da.zip
Add test for custom blitter vs sdl_gfx.
Result: custom is 3x faster.
Diffstat (limited to 'src')
-rw-r--r--src/test/testlauncher.cpp94
-rw-r--r--src/test/testlauncher.h2
2 files changed, 88 insertions, 8 deletions
diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp
index 27516417b..b44726a97 100644
--- a/src/test/testlauncher.cpp
+++ b/src/test/testlauncher.cpp
@@ -54,6 +54,9 @@
#include "resources/image/image.h"
+
+#include <SDL_gfxBlitFunc.h>
+
#include <unistd.h>
#ifdef WIN32
@@ -63,6 +66,18 @@
#include <sys/time.h>
+#include "localconsts.h"
+
+#ifndef SDL_BIG_ENDIAN
+#error missing SDL_endian.h
+#endif // SDL_BYTEORDER
+
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+#ifndef USE_SDL2
+#include "resources/sdlgfxblitfunc.h"
+#endif // USE_SDL2
+#endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
+
#include "debug.h"
extern Font *boldFont;
@@ -112,6 +127,8 @@ int TestLauncher::exec()
return testStackSpeed();
else if (mTest == "107")
return testDyeASpeed();
+ else if (mTest == "108")
+ return testBlitSpeed();
return -1;
}
@@ -485,14 +502,6 @@ int TestLauncher::testDye()
}
#if defined __linux__ || defined __linux
-#ifdef SIMD_SUPPORTED
-static void initBuffer(uint32_t *const buf,
- const int sz)
-{
- for (int f = 0; f < sz; f ++)
- buf[f] = f;
-}
-
static void calcTime(const char *const msg1,
const char *const msg2,
const timespec &time1,
@@ -508,6 +517,14 @@ static void calcTime(const char *const msg1,
printf("%s: %011ld\n", msg2, diff);
}
+#ifdef SIMD_SUPPORTED
+static void initBuffer(uint32_t *const buf,
+ const int sz)
+{
+ for (int f = 0; f < sz; f ++)
+ buf[f] = f;
+}
+
#define runDyeTest(msg1, msg2, func) \
initBuffer(buf, sz); \
pal.func(buf, sz); \
@@ -560,6 +577,67 @@ int TestLauncher::testDyeASpeed()
return 0;
}
+int TestLauncher::testBlitSpeed()
+{
+#if defined __linux__ || defined __linux
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+#ifndef USE_SDL2
+
+ timespec time1;
+ timespec time2;
+ const int cnt1 = 10000;
+ const int cnt2 = 10;
+
+ SDL_Surface *const srcSurface = imageHelper->create32BitSurface(
+ 64, 64);
+ SDL_Surface *const dstSurface = imageHelper->create32BitSurface(
+ 512, 512);
+ for (int f = 0; f < 64 * 64; f ++)
+ static_cast<uint32_t*>(srcSurface->pixels)[f] = 0x11223344;
+ clock_gettime(CLOCK_MONOTONIC, &time1);
+ for (int d = 0; d < cnt2; d ++)
+ {
+ for (int f = 0; f < 512 * 512; f ++)
+ static_cast<uint32_t*>(dstSurface->pixels)[f] = 0x55667788;
+ for (int f = 0; f < cnt1; f ++)
+ {
+ SDLgfxBlitRGBA(srcSurface,
+ nullptr,
+ dstSurface,
+ nullptr);
+ }
+ }
+ calcTime("blit test",
+ "custom time",
+ time1,
+ time2,
+ static_cast<uint32_t*>(dstSurface->pixels));
+
+ clock_gettime(CLOCK_MONOTONIC, &time1);
+ for (int d = 0; d < cnt2; d ++)
+ {
+ for (int f = 0; f < 512 * 512; f ++)
+ static_cast<uint32_t*>(dstSurface->pixels)[f] = 0x55667788;
+ for (int f = 0; f < cnt1; f ++)
+ {
+ SDL_gfxBlitRGBA(srcSurface,
+ nullptr,
+ dstSurface,
+ nullptr);
+ }
+ }
+ calcTime("blit test",
+ "SDL_gfx time",
+ time1,
+ time2,
+ static_cast<uint32_t*>(dstSurface->pixels));
+
+#endif // USE_SDL2
+#endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
+#endif // defined __linux__ || defined __linux
+ return 0;
+}
+
int TestLauncher::testStackSpeed()
{
/*
diff --git a/src/test/testlauncher.h b/src/test/testlauncher.h
index 136dc0250..efd0eea2b 100644
--- a/src/test/testlauncher.h
+++ b/src/test/testlauncher.h
@@ -80,6 +80,8 @@ class TestLauncher final
int testStackSpeed();
+ int testBlitSpeed();
+
private:
std::string mTest;