diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:25:12 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:25:12 +0000 |
commit | 827a4c3faa27e0c186452585b15094eee1119085 (patch) | |
tree | e6a08b0c767863d66f7d4a9de80db5edc7db29be /libfreerdp/primitives/test | |
parent | Releasing progress-linux version 3.3.0+dfsg1-1~progress7.99u1. (diff) | |
download | freerdp3-827a4c3faa27e0c186452585b15094eee1119085.tar.xz freerdp3-827a4c3faa27e0c186452585b15094eee1119085.zip |
Merging upstream version 3.5.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libfreerdp/primitives/test')
-rw-r--r-- | libfreerdp/primitives/test/measure.h | 59 | ||||
-rw-r--r-- | libfreerdp/primitives/test/prim_test.c | 26 |
2 files changed, 33 insertions, 52 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); \ diff --git a/libfreerdp/primitives/test/prim_test.c b/libfreerdp/primitives/test/prim_test.c index ede8316..5ec85f8 100644 --- a/libfreerdp/primitives/test/prim_test.c +++ b/libfreerdp/primitives/test/prim_test.c @@ -36,31 +36,15 @@ int test_sizes[] = { 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 }; /* ------------------------------------------------------------------------- */ -#ifdef _WIN32 -float _delta_time(const struct timespec* t0, const struct timespec* t1) +float measure_delta_time(UINT64 t0, UINT64 t1) { - return 0.0f; + INT64 diff = (INT64)(t1 - t0); + double retval = diff / 1000000000.0; + return (retval < 0.0) ? 0.0f : (float)retval; } -#else -float _delta_time(const struct timespec* t0, const struct timespec* t1) -{ - INT64 secs = (INT64)(t1->tv_sec) - (INT64)(t0->tv_sec); - long nsecs = t1->tv_nsec - t0->tv_nsec; - double retval = NAN; - - if (nsecs < 0) - { - --secs; - nsecs += 1000000000; - } - - retval = (double)secs + (double)nsecs / (double)1000000000.0; - return (retval < 0.0) ? 0.0 : (float)retval; -} -#endif /* ------------------------------------------------------------------------- */ -void _floatprint(float t, char* output) +void measure_floatprint(float t, char* output) { /* I don't want to link against -lm, so avoid log,exp,... */ float f = 10.0; |