]> code.delx.au - pulseaudio/blob - src/tests/runtime-test-util.h
channelmap: Add 2.1 surround
[pulseaudio] / src / tests / runtime-test-util.h
1 /***
2 This file is part of PulseAudio.
3
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.
8
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.
13 ***/
14
15 #ifndef fooruntimetestutilhfoo
16 #define fooruntimetestutilhfoo
17
18 #ifdef HAVE_CONFIG_H
19 #include <config.h>
20 #endif
21
22 #include <math.h>
23
24 #include <pulsecore/macro.h>
25 #include <pulse/rtclock.h>
26
27 #define PA_RUNTIME_TEST_RUN_START(l, t1, t2) \
28 { \
29 int _j, _k; \
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); \
35 \
36 for (_k = 0; _k < _times2; _k++) { \
37 _start = pa_rtclock_now(); \
38 for (_j = 0; _j < _times; _j++)
39
40 #define PA_RUNTIME_TEST_RUN_STOP \
41 _stop = pa_rtclock_now(); \
42 \
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); \
47 } \
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); \
54 }
55
56 #endif