Use correct clock for GS fps calculations on unix

This commit is contained in:
TellowKrinkle 2020-08-08 15:01:29 -05:00 committed by tellowkrinkle
parent 37e2142cca
commit ad29594d08
1 changed files with 5 additions and 3 deletions

View File

@ -34,10 +34,12 @@ void GSPerfMon::Put(counter_t c, double val)
if (c == Frame)
{
#if defined(__unix__) || defined(__APPLE__)
// 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);
# ifdef CLOCK_MONOTONIC_RAW
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
# else
clock_gettime(CLOCK_MONOTONIC, &ts);
# endif
uint64 now = (uint64)ts.tv_sec * (uint64)1e6 + (uint64)ts.tv_nsec / (uint64)1e3;
#else
clock_t now = clock();