]>
code.delx.au - pulseaudio/blob - src/tests/runtime-test-util.h
2 This file is part of PulseAudio.
4 PulseAudio is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 2.1 of the License,
7 or (at your option) any later version.
9 PulseAudio is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
15 #ifndef fooruntimetestutilhfoo
16 #define fooruntimetestutilhfoo
24 #include <pulsecore/macro.h>
25 #include <pulse/rtclock.h>
27 #define PA_RUNTIME_TEST_RUN_START(l, t1, t2) \
30 int _times = (t1), _times2 = (t2); \
31 pa_usec_t _start, _stop; \
32 pa_usec_t _min = INT_MAX, _max = 0; \
33 double _s1 = 0, _s2 = 0; \
34 const char *_label = (l); \
36 for (_k = 0; _k < _times2; _k++) { \
37 _start = pa_rtclock_now(); \
38 for (_j = 0; _j < _times; _j++)
40 #define PA_RUNTIME_TEST_RUN_STOP \
41 _stop = pa_rtclock_now(); \
43 if (_min > (_stop - _start)) _min = _stop - _start; \
44 if (_max < (_stop - _start)) _max = _stop - _start; \
45 _s1 += _stop - _start; \
46 _s2 += (_stop - _start) * (_stop - _start); \
48 pa_log_debug("%s: %llu usec (avg: %g, min = %llu, max = %llu, stddev = %g).", _label, \
49 (long long unsigned int)_s1, \
50 ((double)_s1 / _times2), \
51 (long long unsigned int)_min, \
52 (long long unsigned int)_max, \
53 sqrt(_times2 * _s2 - _s1 * _s1) / _times2); \