Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ endif()
# Options
option(LIBROSA_BUILD_TESTS "Build tests" ON)
option(LIBROSA_BUILD_EXAMPLES "Build examples" OFF)
option(LIBROSA_BUILD_BENCHMARKS "Build Google Benchmark performance benchmarks" OFF)
option(LIBROSA_BUILD_CROSSVAL_TESTS "Build cross-validation tests against Python librosa" OFF)
option(LIBROSA_BUILD_CLI "Build the librosa CLI tool" OFF)
option(LIBROSA_BUILD_WASM "Build the Emscripten WASM/npm binding" OFF)
Expand Down Expand Up @@ -349,6 +350,36 @@ if(LIBROSA_BUILD_TESTS)
endif()
endif()

# Benchmarks
if(LIBROSA_BUILD_BENCHMARKS)
include(FetchContent)
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable benchmark tests" FORCE)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable benchmark gtest tests" FORCE)
FetchContent_Declare(
googlebenchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.8.5
)
FetchContent_MakeAvailable(googlebenchmark)

add_executable(librosa_benchmarks
benchmarks/algorithm_benchmark.cpp
benchmarks/beat_benchmark.cpp
benchmarks/core_benchmark.cpp
benchmarks/feature_benchmark.cpp
benchmarks/onset_beat_benchmark.cpp
benchmarks/utility_benchmark.cpp
)
target_link_libraries(librosa_benchmarks
PRIVATE
librosa::librosa
benchmark::benchmark_main
)
if(LIBROSA_USE_AUDIOTOOLBOX)
target_compile_definitions(librosa_benchmarks PRIVATE LIBROSA_HAS_AUDIOTOOLBOX)
endif()
endif()

# Examples
if(LIBROSA_BUILD_EXAMPLES)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/load_audio.cpp")
Expand Down
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ Bundled (no action needed):

- Eigen (git submodule at `modules/eigen`)
- `fnnls`, `incbeta` (vendored in `vendor/`)
- GoogleTest and CLI11 fetched on demand via CMake `FetchContent`
- GoogleTest, Google Benchmark, and CLI11 fetched on demand via CMake
`FetchContent`

On Ubuntu:

Expand Down Expand Up @@ -125,6 +126,28 @@ ctest --test-dir build --output-on-failure
The default unit tests are self-contained — they synthesise their own signals
and do not require any external data.

## Run performance benchmarks

Google Benchmark targets are optional and off by default:

```bash
cmake -S . -B build-perf \
-DCMAKE_BUILD_TYPE=Release \
-DLIBROSA_BUILD_TESTS=OFF \
-DLIBROSA_BUILD_BENCHMARKS=ON
cmake --build build-perf --target librosa_benchmarks
./build-perf/librosa_benchmarks
```

Real-file beat/onset benchmarks are disabled unless `LIBROSA_BENCH_AUDIO` is
set. This keeps local paths out of the build while still allowing benchmarks on
long production tracks:

```bash
LIBROSA_BENCH_AUDIO="/path/to/file.wav" \
./build-perf/librosa_benchmarks --benchmark_filter=RealAudio
```

## Swift Package

This repository is also a Swift 5.9+ package for Apple platforms. The package
Expand Down
Loading
Loading