Add option to print render time of each frame to log file

Signed-off-by: Vojtech Bocek <vbocek@gmail.com>

Change-Id: Id158a6375fbadf4cdf0a8c7d143759e602419e7f
diff --git a/gui/gui.cpp b/gui/gui.cpp
index e9efc1d..adc8a41 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -57,6 +57,9 @@
 #include "blanktimer.hpp"
 #endif
 
+// Enable to print render time of each frame to the log file
+//#define PRINT_RENDER_TIME 1
+
 const static int CURTAIN_FADE = 32;
 
 using namespace rapidxml;
@@ -423,6 +426,11 @@
 
 	DataManager::SetValue("tw_loaded", 1);
 
+#ifdef PRINT_RENDER_TIME
+	timespec start, end;
+	int32_t render_t, flip_t;
+#endif
+
 	for (;;)
 	{
 		loopTimer();
@@ -432,11 +440,30 @@
 			int ret;
 
 			ret = PageManager::Update();
+
+#ifndef PRINT_RENDER_TIME
 			if (ret > 1)
 				PageManager::Render();
 
 			if (ret > 0)
 				flip();
+#else
+			if (ret > 1)
+			{
+				clock_gettime(CLOCK_MONOTONIC, &start);
+				PageManager::Render();
+				clock_gettime(CLOCK_MONOTONIC, &end);
+				render_t = TWFunc::timespec_diff_ms(start, end);
+
+				flip();
+				clock_gettime(CLOCK_MONOTONIC, &start);
+				flip_t = TWFunc::timespec_diff_ms(end, start);
+
+				LOGINFO("Render(): %u ms, flip(): %u ms, total: %u ms\n", render_t, flip_t, render_t+flip_t);
+			}
+			else if(ret == 1)
+				flip();
+#endif
 		}
 		else
 		{