Use the installed benchmark library
This commit is contained in:
parent
313aed391c
commit
1ddee559f1
3 changed files with 26 additions and 54 deletions
|
|
@ -30,11 +30,11 @@
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
#include "libnyquist/Decoders.h"
|
// #include "libnyquist/Decoders.h"
|
||||||
|
|
||||||
class FileFixture : public benchmark::Fixture {
|
class FileFixture : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
void SetUp(const ::benchmark::State& state) {
|
void SetUp(const ::benchmark::State& state [[maybe_unused]]) {
|
||||||
filePath1 = getPath() / "sample1.flac";
|
filePath1 = getPath() / "sample1.flac";
|
||||||
filePath2 = getPath() / "sample2.flac";
|
filePath2 = getPath() / "sample2.flac";
|
||||||
filePath3 = getPath() / "sample3.flac";
|
filePath3 = getPath() / "sample3.flac";
|
||||||
|
|
@ -90,17 +90,17 @@ BENCHMARK_DEFINE_F(FileFixture, DrFlac)(benchmark::State& state) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BENCHMARK_DEFINE_F(FileFixture, LibNyquist)(benchmark::State& state) {
|
// BENCHMARK_DEFINE_F(FileFixture, LibNyquist)(benchmark::State& state) {
|
||||||
for (auto _ : state)
|
// for (auto _ : state)
|
||||||
{
|
// {
|
||||||
nqr::AudioData data;
|
// nqr::AudioData data;
|
||||||
nqr::NyquistIO loader;
|
// nqr::NyquistIO loader;
|
||||||
loader.Load(&data, filePath3.string());
|
// loader.Load(&data, filePath3.string());
|
||||||
benchmark::DoNotOptimize(data);
|
// benchmark::DoNotOptimize(data);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
BENCHMARK_REGISTER_F(FileFixture, SndFile);
|
BENCHMARK_REGISTER_F(FileFixture, SndFile);
|
||||||
BENCHMARK_REGISTER_F(FileFixture, DrFlac);
|
BENCHMARK_REGISTER_F(FileFixture, DrFlac);
|
||||||
BENCHMARK_REGISTER_F(FileFixture, LibNyquist);
|
// BENCHMARK_REGISTER_F(FileFixture, LibNyquist);
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,11 @@
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
#include "libnyquist/Decoders.h"
|
// #include "libnyquist/Decoders.h"
|
||||||
|
|
||||||
class FileFixture : public benchmark::Fixture {
|
class FileFixture : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
void SetUp(const ::benchmark::State& state) {
|
void SetUp(const ::benchmark::State& state [[maybe_unused]]) {
|
||||||
filePath1 = getPath() / "sample1.wav";
|
filePath1 = getPath() / "sample1.wav";
|
||||||
filePath2 = getPath() / "sample2.wav";
|
filePath2 = getPath() / "sample2.wav";
|
||||||
filePath3 = getPath() / "sample3.wav";
|
filePath3 = getPath() / "sample3.wav";
|
||||||
|
|
@ -96,17 +96,17 @@ BENCHMARK_DEFINE_F(FileFixture, DrWav)(benchmark::State& state) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BENCHMARK_DEFINE_F(FileFixture, LibNyquist)(benchmark::State& state) {
|
// BENCHMARK_DEFINE_F(FileFixture, LibNyquist)(benchmark::State& state) {
|
||||||
for (auto _ : state)
|
// for (auto _ : state)
|
||||||
{
|
// {
|
||||||
nqr::AudioData data;
|
// nqr::AudioData data;
|
||||||
nqr::NyquistIO loader;
|
// nqr::NyquistIO loader;
|
||||||
loader.Load(&data, filePath3.string());
|
// loader.Load(&data, filePath3.string());
|
||||||
benchmark::DoNotOptimize(data);
|
// benchmark::DoNotOptimize(data);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
BENCHMARK_REGISTER_F(FileFixture, SndFile);
|
BENCHMARK_REGISTER_F(FileFixture, SndFile);
|
||||||
BENCHMARK_REGISTER_F(FileFixture, DrWav);
|
BENCHMARK_REGISTER_F(FileFixture, DrWav);
|
||||||
BENCHMARK_REGISTER_F(FileFixture, LibNyquist);
|
// BENCHMARK_REGISTER_F(FileFixture, LibNyquist);
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,5 @@
|
||||||
project(sfizz)
|
project(sfizz)
|
||||||
|
|
||||||
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable Google Benchmark tests")
|
|
||||||
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Disable Google Benchmark install")
|
|
||||||
|
|
||||||
include(FetchContent)
|
|
||||||
FetchContent_Declare(
|
|
||||||
benchmark
|
|
||||||
GIT_REPOSITORY https://github.com/google/benchmark.git
|
|
||||||
GIT_TAG v1.5.0
|
|
||||||
)
|
|
||||||
|
|
||||||
FetchContent_GetProperties(benchmark)
|
|
||||||
if(NOT benchmark_POPULATED)
|
|
||||||
FetchContent_Populate(benchmark)
|
|
||||||
add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Check SIMD
|
# Check SIMD
|
||||||
include (SfizzSIMDSourceFilesCheck)
|
include (SfizzSIMDSourceFilesCheck)
|
||||||
set(BENCHMARK_SIMD_SOURCES ${SFIZZ_SIMD_SOURCES})
|
set(BENCHMARK_SIMD_SOURCES ${SFIZZ_SIMD_SOURCES})
|
||||||
|
|
@ -119,25 +103,13 @@ add_executable(bm_envelopes BM_envelopes.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_envelopes PRIVATE benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_envelopes PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_envelopes PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_envelopes PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
include(FetchContent)
|
|
||||||
FetchContent_Declare(
|
|
||||||
libnyquist
|
|
||||||
GIT_REPOSITORY https://github.com/paulfd/libnyquist
|
|
||||||
)
|
|
||||||
|
|
||||||
FetchContent_GetProperties(libnyquist)
|
|
||||||
if(NOT libnyquist_POPULATED)
|
|
||||||
FetchContent_Populate(libnyquist)
|
|
||||||
add_subdirectory(${libnyquist_SOURCE_DIR} ${libnyquist_BINARY_DIR} EXCLUDE_FROM_ALL)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable(bm_wavfile BM_wavfile.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_wavfile BM_wavfile.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_wavfile PRIVATE benchmark absl::span absl::algorithm libnyquist)
|
target_link_libraries(bm_wavfile PRIVATE benchmark absl::span absl::algorithm)
|
||||||
sfizz_link_libsndfile(bm_wavfile)
|
sfizz_link_libsndfile(bm_wavfile)
|
||||||
target_include_directories(bm_wavfile PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_wavfile PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_flacfile BM_flacfile.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_flacfile BM_flacfile.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_flacfile PRIVATE benchmark absl::span absl::algorithm libnyquist)
|
target_link_libraries(bm_flacfile PRIVATE benchmark absl::span absl::algorithm)
|
||||||
sfizz_link_libsndfile(bm_flacfile)
|
sfizz_link_libsndfile(bm_flacfile)
|
||||||
target_include_directories(bm_flacfile PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_flacfile PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue