From 1b555ea3b5662787d216a436c2632a5ee48ffbdd Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Mon, 24 Nov 2014 23:44:32 +0100 Subject: [PATCH] gsdx-linux: Fix GSdx internal counter on linux The issue is that clock gives the total cpu time of the process whereas we want the cpu time of the rendering thread --- plugins/GSdx/GSPerfMon.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/GSdx/GSPerfMon.cpp b/plugins/GSdx/GSPerfMon.cpp index 80019c7b2d..b80406a220 100644 --- a/plugins/GSdx/GSPerfMon.cpp +++ b/plugins/GSdx/GSPerfMon.cpp @@ -37,7 +37,15 @@ void GSPerfMon::Put(counter_t c, double val) { if(c == Frame) { +#ifdef __linux__ + // clock on linux will return CLOCK_PROCESS_CPUTIME_ID. + // CLOCK_THREAD_CPUTIME_ID is much more useful to measure the fps + struct timespec ts; + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); + uint64 now = (uint64) ts.tv_sec * (uint64) 1e6 + (uint64) ts.tv_nsec / (uint64) 1e3; +#else clock_t now = clock(); +#endif if(m_lastframe != 0) {