2019-07-30 01:04:12 +02:00
|
|
|
#include <benchmark/benchmark.h>
|
|
|
|
|
#include "../sources/AudioBuffer.h"
|
|
|
|
|
#include <algorithm>
|
2019-07-31 01:45:58 +02:00
|
|
|
#include <numeric>
|
2019-07-30 01:04:12 +02:00
|
|
|
|
2019-07-31 01:45:58 +02:00
|
|
|
static void Joint_Fill_float(benchmark::State& state) {
|
|
|
|
|
AudioBuffer<float> buffer (100001);
|
2019-07-30 01:04:12 +02:00
|
|
|
float fillValue = 0.0f;
|
|
|
|
|
for (auto _ : state) {
|
2019-07-30 18:41:42 +02:00
|
|
|
buffer.fill(fillValue);
|
2019-07-30 01:04:12 +02:00
|
|
|
fillValue += 1.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Register the function as a benchmark
|
2019-07-31 01:45:58 +02:00
|
|
|
BENCHMARK(Joint_Fill_float);
|
2019-07-30 01:04:12 +02:00
|
|
|
|
2019-07-31 01:45:58 +02:00
|
|
|
static void Split_Fill_float(benchmark::State& state) {
|
|
|
|
|
SplitAudioBuffer<float> buffer (100001);
|
2019-07-30 01:04:12 +02:00
|
|
|
float fillValue = 0.0f;
|
|
|
|
|
for (auto _ : state) {
|
2019-07-30 18:41:42 +02:00
|
|
|
buffer.fill(fillValue);
|
2019-07-30 01:04:12 +02:00
|
|
|
fillValue += 1.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-31 01:45:58 +02:00
|
|
|
BENCHMARK(Split_Fill_float);
|
2019-07-30 01:04:12 +02:00
|
|
|
|
2019-07-31 01:45:58 +02:00
|
|
|
static void Joint_Fill_float_SSE(benchmark::State& state) {
|
|
|
|
|
AudioBuffer<float> buffer (100001);
|
|
|
|
|
float fillValue = 0.0f;
|
|
|
|
|
for (auto _ : state) {
|
|
|
|
|
buffer.fill<VectorOperations::sse>(fillValue);
|
|
|
|
|
fillValue += 1.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Register the function as a benchmark
|
|
|
|
|
BENCHMARK(Joint_Fill_float_SSE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void Split_Fill_float_SSE(benchmark::State& state) {
|
|
|
|
|
SplitAudioBuffer<float> buffer (100001);
|
|
|
|
|
float fillValue = 0.0f;
|
|
|
|
|
for (auto _ : state) {
|
|
|
|
|
buffer.fill<VectorOperations::sse>(fillValue);
|
|
|
|
|
fillValue += 1.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BENCHMARK(Split_Fill_float_SSE);
|
|
|
|
|
|
|
|
|
|
static void Joint_Fill_double(benchmark::State& state) {
|
|
|
|
|
AudioBuffer<double> buffer (100001);
|
2019-07-30 01:04:12 +02:00
|
|
|
double fillValue = 0.0;
|
|
|
|
|
for (auto _ : state) {
|
2019-07-30 18:41:42 +02:00
|
|
|
buffer.fill(fillValue);
|
2019-07-30 01:04:12 +02:00
|
|
|
fillValue += 1.0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Register the function as a benchmark
|
2019-07-31 01:45:58 +02:00
|
|
|
BENCHMARK(Joint_Fill_double);
|
2019-07-30 01:04:12 +02:00
|
|
|
|
2019-07-31 01:45:58 +02:00
|
|
|
static void Split_Fill_double(benchmark::State& state) {
|
|
|
|
|
SplitAudioBuffer<double> buffer (100001);
|
2019-07-30 01:04:12 +02:00
|
|
|
double fillValue = 0.0;
|
|
|
|
|
for (auto _ : state) {
|
2019-07-30 18:41:42 +02:00
|
|
|
buffer.fill(fillValue);
|
2019-07-30 01:04:12 +02:00
|
|
|
fillValue += 1.0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-31 01:45:58 +02:00
|
|
|
|
|
|
|
|
BENCHMARK(Split_Fill_double);
|
2019-07-30 16:58:47 +02:00
|
|
|
BENCHMARK_MAIN();
|