summaryrefslogtreecommitdiff
path: root/src/commands.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-04-24 00:38:49 +0300
committerAndrei Karas <akaras@inbox.ru>2013-04-24 00:38:49 +0300
commit0afe8cacab876c9c95ad551468f5d6c41eb8720d (patch)
tree1267f8ab43c8bb271428a2e906a8989bf56b84f7 /src/commands.cpp
parent4f2eefafb015c5ab539a1a18515ca959370a861e (diff)
downloadmv-0afe8cacab876c9c95ad551468f5d6c41eb8720d.tar.gz
mv-0afe8cacab876c9c95ad551468f5d6c41eb8720d.tar.bz2
mv-0afe8cacab876c9c95ad551468f5d6c41eb8720d.tar.xz
mv-0afe8cacab876c9c95ad551468f5d6c41eb8720d.zip
add command for test perfomance in sdlfont calculation.
Diffstat (limited to 'src/commands.cpp')
-rw-r--r--src/commands.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/commands.cpp b/src/commands.cpp
index 9044a83a5..9dd4267fe 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -30,6 +30,7 @@
#include "guildmanager.h"
#include "localplayer.h"
#include "main.h"
+#include "nullopenglgraphics.h"
#include "party.h"
#include "gui/chatwindow.h"
@@ -1065,6 +1066,47 @@ impHandler1(execute)
execFile(name, name, params, "");
}
+impHandler0(testsdlfont)
+{
+#if defined USE_OPENGL && defined DEBUG_SDLFONT
+ SDLFont *font = new SDLFont("fonts/dejavusans.ttf", 18);
+ timespec time1;
+ timespec time2;
+ NullOpenGLGraphics *nullGraphics = new NullOpenGLGraphics;
+ std::vector<std::string> data;
+ int width = 0;
+
+ for (int f = 0; f < 300; f ++)
+ data.push_back("test " + toString(f) + "string");
+ nullGraphics->_beginDraw();
+
+ clock_gettime(CLOCK_MONOTONIC, &time1);
+ for (int f = 0; f < 500; f ++)
+ {
+ FOR_EACH (std::vector<std::string>::const_iterator, it, data)
+ {
+ width += font->getWidth(*it);
+ font->drawString(nullGraphics, *it, 10, 10);
+ }
+ FOR_EACH (std::vector<std::string>::const_iterator, it, data)
+ font->drawString(nullGraphics, *it, 10, 10);
+ }
+
+ clock_gettime(CLOCK_MONOTONIC, &time2);
+
+ delete nullGraphics;
+ delete font;
+
+ long int diff = (static_cast<long long int>(
+ time2.tv_sec) * 1000000000LL + static_cast<long long int>(
+ time2.tv_nsec)) / 100000 - (static_cast<long long int>(
+ time1.tv_sec) * 1000000000LL + static_cast<long long int>(
+ time1.tv_nsec)) / 100000;
+ if (debugChatTab)
+ debugChatTab->chatLog("sdlfont time: " + toString(diff));
+#endif
+}
+
#ifdef DEBUG_DUMP_LEAKS1
void showRes(std::string str, ResourceManager::Resources *res);