| /*** | |
| 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 |