summaryrefslogtreecommitdiff
path: root/src/tests/runtime-test-util.h
diff options
context:
space:
mode:
authorPeter Meerwald <pmeerw@pmeerw.net>2013-07-16 22:00:35 +0200
committerDavid Henningsson <david.henningsson@canonical.com>2013-11-01 15:02:24 +0100
commite8a84270c326ff2a84d99a057d89e5ded2f03929 (patch)
tree90d7a48bef768ca255965b3377f4b18a4d6556d5 /src/tests/runtime-test-util.h
parent4262d6a14f6292a5f3a883ce82b4edad230ee16f (diff)
tests: Extract PA_CPU_TEST* macros to separate header
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Diffstat (limited to 'src/tests/runtime-test-util.h')
-rw-r--r--src/tests/runtime-test-util.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/tests/runtime-test-util.h b/src/tests/runtime-test-util.h
new file mode 100644
index 00000000..7d3443ab
--- /dev/null
+++ b/src/tests/runtime-test-util.h
@@ -0,0 +1,56 @@
+/***
+ This file is part of PulseAudio.
+
+ PulseAudio is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License,
+ or (at your option) any later version.
+
+ PulseAudio is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+***/
+
+#ifndef fooruntimetestutilhfoo
+#define fooruntimetestutilhfoo
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <math.h>
+
+#include <pulsecore/macro.h>
+#include <pulse/rtclock.h>
+
+#define PA_RUNTIME_TEST_RUN_START(l, t1, t2) \
+{ \
+ int _j, _k; \
+ int _times = (t1), _times2 = (t2); \
+ pa_usec_t _start, _stop; \
+ pa_usec_t _min = INT_MAX, _max = 0; \
+ double _s1 = 0, _s2 = 0; \
+ const char *_label = (l); \
+ \
+ for (_k = 0; _k < _times2; _k++) { \
+ _start = pa_rtclock_now(); \
+ for (_j = 0; _j < _times; _j++)
+
+#define PA_RUNTIME_TEST_RUN_STOP \
+ _stop = pa_rtclock_now(); \
+ \
+ if (_min > (_stop - _start)) _min = _stop - _start; \
+ if (_max < (_stop - _start)) _max = _stop - _start; \
+ _s1 += _stop - _start; \
+ _s2 += (_stop - _start) * (_stop - _start); \
+ } \
+ pa_log_debug("%s: %llu usec (avg: %g, min = %llu, max = %llu, stddev = %g).", _label, \
+ (long long unsigned int)_s1, \
+ ((double)_s1 / _times2), \
+ (long long unsigned int)_min, \
+ (long long unsigned int)_max, \
+ sqrt(_times2 * _s2 - _s1 * _s1) / _times2); \
+}
+
+#endif