mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
tests: Extract PA_CPU_TEST* macros to separate header
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
This commit is contained in:
parent
4262d6a14f
commit
e8a84270c3
4 changed files with 99 additions and 124 deletions
|
|
@ -36,34 +36,7 @@
|
||||||
#include <pulsecore/sample-util.h>
|
#include <pulsecore/sample-util.h>
|
||||||
#include <pulsecore/mix.h>
|
#include <pulsecore/mix.h>
|
||||||
|
|
||||||
#define PA_CPU_TEST_RUN_START(l, t1, t2) \
|
#include "runtime-test-util.h"
|
||||||
{ \
|
|
||||||
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_CPU_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); \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Common defines for svolume tests */
|
/* Common defines for svolume tests */
|
||||||
#define SAMPLES 1028
|
#define SAMPLES 1028
|
||||||
|
|
@ -121,15 +94,15 @@ static void run_volume_test(
|
||||||
if (perf) {
|
if (perf) {
|
||||||
pa_log_debug("Testing svolume %dch performance with %d sample alignment", channels, align);
|
pa_log_debug("Testing svolume %dch performance with %d sample alignment", channels, align);
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
|
||||||
memcpy(samples, samples_orig, size);
|
memcpy(samples, samples_orig, size);
|
||||||
func(samples, volumes, channels, size);
|
func(samples, volumes, channels, size);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
|
||||||
memcpy(samples_ref, samples_orig, size);
|
memcpy(samples_ref, samples_orig, size);
|
||||||
orig_func(samples_ref, volumes, channels, size);
|
orig_func(samples_ref, volumes, channels, size);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
fail_unless(memcmp(samples_ref, samples, size) == 0);
|
fail_unless(memcmp(samples_ref, samples, size) == 0);
|
||||||
}
|
}
|
||||||
|
|
@ -301,13 +274,13 @@ static void run_conv_test_float_to_s16(
|
||||||
if (perf) {
|
if (perf) {
|
||||||
pa_log_debug("Testing sconv performance with %d sample alignment", align);
|
pa_log_debug("Testing sconv performance with %d sample alignment", align);
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
|
||||||
func(nsamples, floats, samples);
|
func(nsamples, floats, samples);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
|
||||||
orig_func(nsamples, floats, samples_ref);
|
orig_func(nsamples, floats, samples_ref);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -352,13 +325,13 @@ static void run_conv_test_s16_to_float(
|
||||||
if (perf) {
|
if (perf) {
|
||||||
pa_log_debug("Testing sconv performance with %d sample alignment", align);
|
pa_log_debug("Testing sconv performance with %d sample alignment", align);
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
|
||||||
func(nsamples, samples, floats);
|
func(nsamples, samples, floats);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
|
||||||
orig_func(nsamples, samples, floats_ref);
|
orig_func(nsamples, samples, floats_ref);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* HAVE_NEON */
|
#endif /* HAVE_NEON */
|
||||||
|
|
@ -513,13 +486,13 @@ static void run_remap_test_mono_stereo_float(
|
||||||
if (perf) {
|
if (perf) {
|
||||||
pa_log_debug("Testing remap performance with %d sample alignment", align);
|
pa_log_debug("Testing remap performance with %d sample alignment", align);
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
|
||||||
func(remap, stereo, mono, nsamples);
|
func(remap, stereo, mono, nsamples);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
|
||||||
orig_func(remap, stereo_ref, mono, nsamples);
|
orig_func(remap, stereo_ref, mono, nsamples);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -562,13 +535,13 @@ static void run_remap_test_mono_stereo_s16(
|
||||||
if (perf) {
|
if (perf) {
|
||||||
pa_log_debug("Testing remap performance with %d sample alignment", align);
|
pa_log_debug("Testing remap performance with %d sample alignment", align);
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
|
||||||
func(remap, stereo, mono, nsamples);
|
func(remap, stereo, mono, nsamples);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
|
||||||
orig_func(remap, stereo_ref, mono, nsamples);
|
orig_func(remap, stereo_ref, mono, nsamples);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -803,17 +776,17 @@ static void run_mix_test(
|
||||||
if (perf) {
|
if (perf) {
|
||||||
pa_log_debug("Testing %d-channel mixing performance with %d sample alignment", channels, align);
|
pa_log_debug("Testing %d-channel mixing performance with %d sample alignment", channels, align);
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
|
||||||
acquire_mix_streams(m, 2);
|
acquire_mix_streams(m, 2);
|
||||||
func(m, 2, channels, samples, nsamples * sizeof(int16_t));
|
func(m, 2, channels, samples, nsamples * sizeof(int16_t));
|
||||||
release_mix_streams(m, 2);
|
release_mix_streams(m, 2);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
|
||||||
acquire_mix_streams(m, 2);
|
acquire_mix_streams(m, 2);
|
||||||
orig_func(m, 2, channels, samples_ref, nsamples * sizeof(int16_t));
|
orig_func(m, 2, channels, samples_ref, nsamples * sizeof(int16_t));
|
||||||
release_mix_streams(m, 2);
|
release_mix_streams(m, 2);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_memblock_unref(c0.memblock);
|
pa_memblock_unref(c0.memblock);
|
||||||
|
|
|
||||||
|
|
@ -32,34 +32,7 @@
|
||||||
#include <pulsecore/mix.h>
|
#include <pulsecore/mix.h>
|
||||||
#include <pulsecore/sample-util.h>
|
#include <pulsecore/sample-util.h>
|
||||||
|
|
||||||
#define PA_CPU_TEST_RUN_START(l, t1, t2) \
|
#include "runtime-test-util.h"
|
||||||
{ \
|
|
||||||
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_CPU_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); \
|
|
||||||
}
|
|
||||||
|
|
||||||
static void acquire_mix_streams(pa_mix_info streams[], unsigned nstreams) {
|
static void acquire_mix_streams(pa_mix_info streams[], unsigned nstreams) {
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
@ -230,17 +203,17 @@ START_TEST (mix_special_1ch_test) {
|
||||||
m[1].volume.values[0] = PA_VOLUME_NORM;
|
m[1].volume.values[0] = PA_VOLUME_NORM;
|
||||||
m[1].linear[0].i = 0x6789;
|
m[1].linear[0].i = 0x6789;
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("mix s16 generic 1 channel", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("mix s16 generic 1 channel", TIMES, TIMES2) {
|
||||||
acquire_mix_streams(m, 2);
|
acquire_mix_streams(m, 2);
|
||||||
pa_mix_generic_s16ne(m, 2, 1, out_ref, nsamples * sizeof(int16_t));
|
pa_mix_generic_s16ne(m, 2, 1, out_ref, nsamples * sizeof(int16_t));
|
||||||
release_mix_streams(m, 2);
|
release_mix_streams(m, 2);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("mix s16 2 streams 1 channel", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("mix s16 2 streams 1 channel", TIMES, TIMES2) {
|
||||||
acquire_mix_streams(m, 2);
|
acquire_mix_streams(m, 2);
|
||||||
pa_mix2_ch1_s16ne(m, out, nsamples * sizeof(int16_t));
|
pa_mix2_ch1_s16ne(m, out, nsamples * sizeof(int16_t));
|
||||||
release_mix_streams(m, 2);
|
release_mix_streams(m, 2);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
fail_unless(memcmp(out, out_ref, nsamples * sizeof(int16_t)) == 0);
|
fail_unless(memcmp(out, out_ref, nsamples * sizeof(int16_t)) == 0);
|
||||||
|
|
||||||
|
|
@ -288,33 +261,33 @@ START_TEST (mix_special_2ch_test) {
|
||||||
m[1].linear[i].i = 0x6789;
|
m[1].linear[i].i = 0x6789;
|
||||||
}
|
}
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("mix s16 generic 2 channels", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("mix s16 generic 2 channels", TIMES, TIMES2) {
|
||||||
acquire_mix_streams(m, 2);
|
acquire_mix_streams(m, 2);
|
||||||
pa_mix_generic_s16ne(m, 2, 2, out_ref, nsamples * sizeof(int16_t));
|
pa_mix_generic_s16ne(m, 2, 2, out_ref, nsamples * sizeof(int16_t));
|
||||||
release_mix_streams(m, 2);
|
release_mix_streams(m, 2);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("mix s16 2 channels", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("mix s16 2 channels", TIMES, TIMES2) {
|
||||||
acquire_mix_streams(m, 2);
|
acquire_mix_streams(m, 2);
|
||||||
pa_mix_ch2_s16ne(m, 2, out, nsamples * sizeof(int16_t));
|
pa_mix_ch2_s16ne(m, 2, out, nsamples * sizeof(int16_t));
|
||||||
release_mix_streams(m, 2);
|
release_mix_streams(m, 2);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
fail_unless(memcmp(out, out_ref, nsamples * sizeof(int16_t)) == 0);
|
fail_unless(memcmp(out, out_ref, nsamples * sizeof(int16_t)) == 0);
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("mix s16 2 streams", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("mix s16 2 streams", TIMES, TIMES2) {
|
||||||
acquire_mix_streams(m, 2);
|
acquire_mix_streams(m, 2);
|
||||||
pa_mix2_s16ne(m, 2, out, nsamples * sizeof(int16_t));
|
pa_mix2_s16ne(m, 2, out, nsamples * sizeof(int16_t));
|
||||||
release_mix_streams(m, 2);
|
release_mix_streams(m, 2);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
fail_unless(memcmp(out, out_ref, nsamples * sizeof(int16_t)) == 0);
|
fail_unless(memcmp(out, out_ref, nsamples * sizeof(int16_t)) == 0);
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("mix s16 2 streams 2 channels", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("mix s16 2 streams 2 channels", TIMES, TIMES2) {
|
||||||
acquire_mix_streams(m, 2);
|
acquire_mix_streams(m, 2);
|
||||||
pa_mix2_ch2_s16ne(m, out, nsamples * sizeof(int16_t));
|
pa_mix2_ch2_s16ne(m, out, nsamples * sizeof(int16_t));
|
||||||
release_mix_streams(m, 2);
|
release_mix_streams(m, 2);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
fail_unless(memcmp(out, out_ref, nsamples * sizeof(int16_t)) == 0);
|
fail_unless(memcmp(out, out_ref, nsamples * sizeof(int16_t)) == 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,34 +30,7 @@
|
||||||
#include <pulsecore/random.h>
|
#include <pulsecore/random.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
|
||||||
#define PA_CPU_TEST_RUN_START(l, t1, t2) \
|
#include "runtime-test-util.h"
|
||||||
{ \
|
|
||||||
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_CPU_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); \
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int32_t pa_mult_s16_volume_32(int16_t v, int32_t cv) {
|
static inline int32_t pa_mult_s16_volume_32(int16_t v, int32_t cv) {
|
||||||
/* Multiplying the 32 bit volume factor with the
|
/* Multiplying the 32 bit volume factor with the
|
||||||
|
|
@ -98,16 +71,16 @@ START_TEST (mult_s16_test) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("32 bit mult", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("32 bit mult", TIMES, TIMES2) {
|
||||||
for (i = 0; i < SAMPLES; i++) {
|
for (i = 0; i < SAMPLES; i++) {
|
||||||
sum1 += pa_mult_s16_volume_32(samples[i], volumes[i]);
|
sum1 += pa_mult_s16_volume_32(samples[i], volumes[i]);
|
||||||
}
|
}
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
PA_CPU_TEST_RUN_START("64 bit mult", TIMES, TIMES2) {
|
PA_RUNTIME_TEST_RUN_START("64 bit mult", TIMES, TIMES2) {
|
||||||
for (i = 0; i < SAMPLES; i++)
|
for (i = 0; i < SAMPLES; i++)
|
||||||
sum2 += pa_mult_s16_volume_64(samples[i], volumes[i]);
|
sum2 += pa_mult_s16_volume_64(samples[i], volumes[i]);
|
||||||
} PA_CPU_TEST_RUN_STOP
|
} PA_RUNTIME_TEST_RUN_STOP
|
||||||
|
|
||||||
fail_unless(sum1 == sum2);
|
fail_unless(sum1 == sum2);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
56
src/tests/runtime-test-util.h
Normal file
56
src/tests/runtime-test-util.h
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue