Added a couple benchmarks
Clocks are about 20 ns The queue is about 2 us
This commit is contained in:
parent
cb88fb4bb7
commit
1461680e20
3 changed files with 105 additions and 0 deletions
51
benchmarks/BM_clock.cpp
Normal file
51
benchmarks/BM_clock.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
// SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
|
||||||
|
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||||
|
// license. You should have receive a LICENSE.md file along with the code.
|
||||||
|
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||||
|
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
class Clock : public benchmark::Fixture {
|
||||||
|
public:
|
||||||
|
void SetUp(const ::benchmark::State& state) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown(const ::benchmark::State& state [[maybe_unused]]) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
std::chrono::time_point<std::chrono::high_resolution_clock> hires;
|
||||||
|
std::chrono::time_point<std::chrono::steady_clock> steady;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
BENCHMARK_DEFINE_F(Clock, HighRes)(benchmark::State& state) {
|
||||||
|
for (auto _ : state)
|
||||||
|
{
|
||||||
|
hires = std::chrono::high_resolution_clock::now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BENCHMARK_DEFINE_F(Clock, Steady)(benchmark::State& state) {
|
||||||
|
for (auto _ : state)
|
||||||
|
{
|
||||||
|
steady = std::chrono::steady_clock::now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Just checking that stuff happens..
|
||||||
|
BENCHMARK_DEFINE_F(Clock, Both)(benchmark::State& state) {
|
||||||
|
for (auto _ : state)
|
||||||
|
{
|
||||||
|
hires = std::chrono::high_resolution_clock::now();
|
||||||
|
steady = std::chrono::steady_clock::now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BENCHMARK_REGISTER_F(Clock, HighRes);
|
||||||
|
BENCHMARK_REGISTER_F(Clock, Steady);
|
||||||
|
BENCHMARK_REGISTER_F(Clock, Both);
|
||||||
|
BENCHMARK_MAIN();
|
||||||
48
benchmarks/BM_logger.cpp
Normal file
48
benchmarks/BM_logger.cpp
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
// SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
|
||||||
|
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||||
|
// license. You should have receive a LICENSE.md file along with the code.
|
||||||
|
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||||
|
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
|
#include "Logger.h"
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
class Logger : public benchmark::Fixture {
|
||||||
|
public:
|
||||||
|
void SetUp(const ::benchmark::State& state) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown(const ::benchmark::State& state [[maybe_unused]]) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
BENCHMARK_DEFINE_F(Logger, Baseline)(benchmark::State& state) {
|
||||||
|
for (auto _ : state)
|
||||||
|
{
|
||||||
|
sfz::Logger logger {};
|
||||||
|
benchmark::DoNotOptimize(logger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BENCHMARK_DEFINE_F(Logger, ProcessingTime)(benchmark::State& state) {
|
||||||
|
for (auto _ : state)
|
||||||
|
{
|
||||||
|
sfz::Logger logger {};
|
||||||
|
sfz::CallbackBreakdown breakdown;
|
||||||
|
breakdown.data = sfz::Duration(1);
|
||||||
|
breakdown.renderMethod = sfz::Duration(1);
|
||||||
|
breakdown.dispatch = sfz::Duration(1);
|
||||||
|
breakdown.panning = sfz::Duration(1);
|
||||||
|
breakdown.filters = sfz::Duration(1);
|
||||||
|
breakdown.amplitude = sfz::Duration(1);
|
||||||
|
logger.logCallbackTime(std::move(breakdown), 16, 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BENCHMARK_REGISTER_F(Logger, Baseline);
|
||||||
|
BENCHMARK_REGISTER_F(Logger, ProcessingTime);
|
||||||
|
BENCHMARK_MAIN();
|
||||||
|
|
@ -32,6 +32,7 @@ macro(sfizz_add_benchmark TARGET)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
sfizz_add_benchmark(bm_opf_high_vs_low BM_OPF_high_vs_low.cpp)
|
sfizz_add_benchmark(bm_opf_high_vs_low BM_OPF_high_vs_low.cpp)
|
||||||
|
sfizz_add_benchmark(bm_clock BM_clock.cpp)
|
||||||
sfizz_add_benchmark(bm_write BM_writeInterleaved.cpp)
|
sfizz_add_benchmark(bm_write BM_writeInterleaved.cpp)
|
||||||
sfizz_add_benchmark(bm_read BM_readInterleaved.cpp)
|
sfizz_add_benchmark(bm_read BM_readInterleaved.cpp)
|
||||||
sfizz_add_benchmark(bm_fill BM_fill.cpp)
|
sfizz_add_benchmark(bm_fill BM_fill.cpp)
|
||||||
|
|
@ -57,6 +58,9 @@ sfizz_add_benchmark(bm_widthPos BM_widthPos.cpp)
|
||||||
sfizz_add_benchmark(bm_interpolationCast BM_interpolationCast.cpp)
|
sfizz_add_benchmark(bm_interpolationCast BM_interpolationCast.cpp)
|
||||||
sfizz_add_benchmark(bm_pointerIterationOrOffsets BM_pointerIterationOrOffsets.cpp)
|
sfizz_add_benchmark(bm_pointerIterationOrOffsets BM_pointerIterationOrOffsets.cpp)
|
||||||
|
|
||||||
|
sfizz_add_benchmark(bm_logger BM_logger.cpp)
|
||||||
|
target_link_libraries(bm_logger PRIVATE sfizz::sfizz)
|
||||||
|
|
||||||
if (TARGET sfizz-samplerate)
|
if (TARGET sfizz-samplerate)
|
||||||
sfizz_add_benchmark(bm_resample BM_resample.cpp ${BENCHMARK_SIMD_SOURCES})
|
sfizz_add_benchmark(bm_resample BM_resample.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_resample PRIVATE sfizz-samplerate sfizz-sndfile)
|
target_link_libraries(bm_resample PRIVATE sfizz-samplerate sfizz-sndfile)
|
||||||
|
|
@ -86,6 +90,7 @@ add_custom_target(sfizz_benchmarks)
|
||||||
add_dependencies(sfizz_benchmarks
|
add_dependencies(sfizz_benchmarks
|
||||||
bm_opf_high_vs_low
|
bm_opf_high_vs_low
|
||||||
bm_write
|
bm_write
|
||||||
|
bm_clock
|
||||||
bm_pointerIterationOrOffsets
|
bm_pointerIterationOrOffsets
|
||||||
bm_read
|
bm_read
|
||||||
bm_mean
|
bm_mean
|
||||||
|
|
@ -102,6 +107,7 @@ add_dependencies(sfizz_benchmarks
|
||||||
bm_ramp
|
bm_ramp
|
||||||
bm_ADSR
|
bm_ADSR
|
||||||
bm_add
|
bm_add
|
||||||
|
bm_logger
|
||||||
bm_pan
|
bm_pan
|
||||||
bm_subtract
|
bm_subtract
|
||||||
bm_multiplyAdd
|
bm_multiplyAdd
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue