Commit 1b7baed0 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Add limiter performance test: testlimiter perf.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 0adb503a
......@@ -3,6 +3,8 @@
#include <sndfile.h>
#include <assert.h>
#include <math.h>
#include <string.h>
#include <sys/time.h>
#include "sfinputstream.hh"
#include "sfoutputstream.hh"
......@@ -14,10 +16,44 @@ using std::vector;
using std::max;
using std::min;
static double
gettime()
{
timeval tv;
gettimeofday (&tv, 0);
return tv.tv_sec + tv.tv_usec / 1000000.0;
}
int
perf()
{
Limiter limiter (2, 44100);
limiter.set_attack (5);
limiter.set_release (50);
limiter.set_ceiling (1.0);
vector<float> samples (2 * 1024);
int n_frames = 0;
double start = gettime();
for (int i = 0; i < 10000; i++)
{
n_frames += samples.size() / 2;
vector<float> out_samples = limiter.process (samples);
}
double end = gettime();
printf ("%f ns/frame\n", (end - start) * 1000 * 1000 * 1000 / n_frames);
return 0;
}
int
main (int argc, char **argv)
{
if (argc == 2 && strcmp (argv[1], "perf") == 0)
return perf();
SFInputStream in;
SFOutputStream out;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment