diff --git a/benchmarks/BM_clock.cpp b/benchmarks/BM_clock.cpp new file mode 100644 index 00000000..e1a263a3 --- /dev/null +++ b/benchmarks/BM_clock.cpp @@ -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 +#include + +class Clock : public benchmark::Fixture { +public: + void SetUp(const ::benchmark::State& state) { + + } + + void TearDown(const ::benchmark::State& state [[maybe_unused]]) { + + } + + std::chrono::time_point hires; + std::chrono::time_point 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(); diff --git a/benchmarks/BM_logger.cpp b/benchmarks/BM_logger.cpp new file mode 100644 index 00000000..a52bef57 --- /dev/null +++ b/benchmarks/BM_logger.cpp @@ -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 +#include "Logger.h" +#include + +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(); diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index dd7bfb65..00bbd802 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -32,6 +32,7 @@ macro(sfizz_add_benchmark TARGET) endmacro() 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_read BM_readInterleaved.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_pointerIterationOrOffsets BM_pointerIterationOrOffsets.cpp) +sfizz_add_benchmark(bm_logger BM_logger.cpp) +target_link_libraries(bm_logger PRIVATE sfizz::sfizz) + if (TARGET sfizz-samplerate) sfizz_add_benchmark(bm_resample BM_resample.cpp ${BENCHMARK_SIMD_SOURCES}) target_link_libraries(bm_resample PRIVATE sfizz-samplerate sfizz-sndfile) @@ -86,6 +90,7 @@ add_custom_target(sfizz_benchmarks) add_dependencies(sfizz_benchmarks bm_opf_high_vs_low bm_write + bm_clock bm_pointerIterationOrOffsets bm_read bm_mean @@ -102,6 +107,7 @@ add_dependencies(sfizz_benchmarks bm_ramp bm_ADSR bm_add + bm_logger bm_pan bm_subtract bm_multiplyAdd