summaryrefslogtreecommitdiffstats
path: root/libfreerdp/primitives/test/measure.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libfreerdp/primitives/test/measure.h59
1 files changed, 28 insertions, 31 deletions
diff --git a/libfreerdp/primitives/test/measure.h b/libfreerdp/primitives/test/measure.h
index ee04abd..2d4f36e 100644
--- a/libfreerdp/primitives/test/measure.h
+++ b/libfreerdp/primitives/test/measure.h
@@ -29,6 +29,7 @@
#include <time.h>
#include <winpr/string.h>
+#include <winpr/sysinfo.h>
#ifndef _WIN32
#include <sys/param.h>
@@ -69,28 +70,24 @@
#define PROFILER_STOP
#endif // GOOGLE_PROFILER
-extern float _delta_time(const struct timespec* t0, const struct timespec* t1);
-extern void _floatprint(float t, char* output);
-
-#ifndef CLOCK_MONOTONIC_RAW
-#define CLOCK_MONOTONIC_RAW 4
-#endif // !CLOCK_MONOTONIC_RAW
-
-#define MEASURE_LOOP_START(_prefix_, _count_) \
- { \
- struct timespec _start, _stop; \
- char* _prefix; \
- int _count = (_count_); \
- int _loop; \
- float _delta; \
- char _str1[32], _str2[32]; \
- _prefix = _strdup(_prefix_); \
- _str1[0] = '\0'; \
- _str2[0] = '\0'; \
- clock_gettime(CLOCK_MONOTONIC_RAW, &_start); \
- PROFILER_START(_prefix); \
- _loop = (_count); \
- do \
+extern float measure_delta_time(UINT64 t0, UINT64 t1);
+extern void measure_floatprint(float t, char* output);
+
+#define MEASURE_LOOP_START(_prefix_, _count_) \
+ { \
+ UINT64 _start, _stop; \
+ char* _prefix; \
+ int _count = (_count_); \
+ int _loop; \
+ float _delta; \
+ char _str1[32], _str2[32]; \
+ _prefix = _strdup(_prefix_); \
+ _str1[0] = '\0'; \
+ _str2[0] = '\0'; \
+ _start = winpr_GetTickCount64NS(); \
+ PROFILER_START(_prefix); \
+ _loop = (_count); \
+ do \
{
#define MEASURE_LOOP_STOP \
@@ -100,28 +97,28 @@ extern void _floatprint(float t, char* output);
#define MEASURE_GET_RESULTS(_result_) \
PROFILER_STOP; \
- clock_gettime(CLOCK_MONOTONIC_RAW, &_stop); \
- _delta = _delta_time(&_start, &_stop); \
+ _stop = winpr_GetTickCount64NS(); \
+ _delta = measure_delta_time(_start, _stop); \
(_result_) = (float)_count / _delta; \
free(_prefix); \
}
#define MEASURE_SHOW_RESULTS(_result_) \
PROFILER_STOP; \
- clock_gettime(CLOCK_MONOTONIC_RAW, &_stop); \
- _delta = _delta_time(&_start, &_stop); \
+ _stop = winpr_GetTickCount64NS(); \
+ _delta = measure_delta_time(_start, _stop); \
(_result_) = (float)_count / _delta; \
- _floatprint((float)_count / _delta, _str1); \
+ measure_floatprint((float)_count / _delta, _str1); \
printf("%s: %9d iterations in %5.1f seconds = %s/s \n", _prefix, _count, _delta, _str1); \
free(_prefix); \
}
#define MEASURE_SHOW_RESULTS_SCALED(_scale_, _label_) \
PROFILER_STOP; \
- clock_gettime(CLOCK_MONOTONIC_RAW, &_stop); \
- _delta = _delta_time(&_start, &_stop); \
- _floatprint((float)_count / _delta, _str1); \
- _floatprint((float)_count / _delta * (_scale_), _str2); \
+ _stop = winpr_GetTickCount64NS(); \
+ _delta = measure_delta_time(_start, _stop); \
+ measure_floatprint((float)_count / _delta, _str1); \
+ measure_floatprint((float)_count / _delta * (_scale_), _str2); \
printf("%s: %9d iterations in %5.1f seconds = %s/s = %s%s \n", _prefix, _count, _delta, _str1, \
_str2, _label_); \
free(_prefix); \