utils: fix broken stopwatch implementation

Stopwatch (in the way it is used) must be able to measure the wall
clock time with high resolution but used clock() which is not
appropriate for this purpose:
On POSIX systems clock() returns the processor time used by the
program. On Windows clock() does measure the wall clock time but
has only a resolution of 1ms (if at all).
This also renders the freerdp profiler unusable.

This commit changes stopwatch to use the performance counters
on Windows and gettimeofday() for the rest.

Also added a warning about invalid profiling results to the
RemoteFX codec if rfxcontext->priv->UseThreads is enabled because
stopwatch is currently not used in a thread safe way.

Also see GitHub Issue #1325
This commit is contained in:
Norbert Federa
2013-06-27 13:00:54 +02:00
parent 4d47514428
commit b2108839b0
3 changed files with 34 additions and 21 deletions

View File

@@ -20,17 +20,15 @@
#ifndef FREERDP_UTILS_STOPWATCH_H
#define FREERDP_UTILS_STOPWATCH_H
#include <time.h>
#include <freerdp/api.h>
#include <freerdp/types.h>
struct _STOPWATCH
{
clock_t start;
clock_t end;
double elapsed;
clock_t count;
UINT64 start;
UINT64 end;
UINT64 elapsed;
UINT32 count;
};
typedef struct _STOPWATCH STOPWATCH;