You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.2KB

  1. #include <benchmark/benchmark.h>
  2. #include "dsp/oscillator.hpp"
  3. using namespace bogaudio::dsp;
  4. static void BM_Phasor(benchmark::State& state) {
  5. Phasor p(44100.0, 440.0);
  6. for (auto _ : state) {
  7. p.next();
  8. }
  9. }
  10. BENCHMARK(BM_Phasor);
  11. static void BM_SineOscillator(benchmark::State& state) {
  12. SineOscillator o(44100.0, 440.0);
  13. for (auto _ : state) {
  14. o.next();
  15. }
  16. }
  17. BENCHMARK(BM_SineOscillator);
  18. static void BM_SawOscillator(benchmark::State& state) {
  19. SawOscillator o(44100.0, 440.0);
  20. for (auto _ : state) {
  21. o.next();
  22. }
  23. }
  24. BENCHMARK(BM_SawOscillator);
  25. static void BM_SquareOscillator(benchmark::State& state) {
  26. SquareOscillator o(44100.0, 440.0);
  27. for (auto _ : state) {
  28. o.next();
  29. }
  30. }
  31. BENCHMARK(BM_SquareOscillator);
  32. static void BM_TriangleOscillator(benchmark::State& state) {
  33. TriangleOscillator o(44100.0, 440.0);
  34. for (auto _ : state) {
  35. o.next();
  36. }
  37. }
  38. BENCHMARK(BM_TriangleOscillator);
  39. static void BM_SineBankOscillator(benchmark::State& state) {
  40. SineBankOscillator o(44100.0, 440.0, 100);
  41. for (int i = 1, n = o.partialCount(); i <= n; ++i) {
  42. o.setPartial(i, i, 1.0 / (float)i);
  43. }
  44. for (auto _ : state) {
  45. o.next();
  46. }
  47. }
  48. BENCHMARK(BM_SineBankOscillator);