Skip to content

Commit c2817da

Browse files
Nathan LeeChromeos LUCI
Nathan Lee
authored and
Chromeos LUCI
committed
cras: dsp: Add eq test to dsp_benchmark
Add eq benchmark test for the following efficiency validating of the eq.c porting BUG=b:352433455 TEST=bazel test //... Change-Id: Ie68cb3ac8ba670aaf6741566c89f7bb114cd269b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5706729 Reviewed-by: Li-Yu Yu <[email protected]> Tested-by: [email protected] <[email protected]> Commit-Queue: Nathan Lee <[email protected]>
1 parent c8d6308 commit c2817da

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

cras/benchmark/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ cc_library(
3232
":benchmark_util",
3333
"//cras/src/dsp:drc",
3434
"//cras/src/dsp:dsp_util",
35+
"//cras/src/dsp:eq",
3536
"//cras/src/dsp:eq2",
3637
"//cras/src/server:cras_mix",
3738
"@com_github_google_benchmark//:benchmark",

cras/benchmark/dsp_benchmark.cc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#include "cras/benchmark/benchmark_util.hh"
1111
#include "cras/src/dsp/biquad.h"
1212
#include "cras/src/dsp/drc.h"
13+
#include "cras/src/dsp/eq.h"
1314
#include "cras/src/dsp/eq2.h"
15+
#include "cras/src/dsp/rust/dsp.h"
1416

1517
namespace {
1618

@@ -33,6 +35,29 @@ class BM_Dsp : public benchmark::Fixture {
3335
std::vector<float> samples;
3436
};
3537

38+
BENCHMARK_DEFINE_F(BM_Dsp, Eq)(benchmark::State& state) {
39+
const double NQ = 44100 / 2; // nyquist frequency
40+
// eq chain
41+
struct eq* eq = eq_new();
42+
eq_append_biquad(eq, BQ_PEAKING, 380 / NQ, 3, -10);
43+
eq_append_biquad(eq, BQ_PEAKING, 720 / NQ, 3, -12);
44+
eq_append_biquad(eq, BQ_PEAKING, 1705 / NQ, 3, -8);
45+
eq_append_biquad(eq, BQ_HIGHPASS, 218 / NQ, 0.7, -10.2);
46+
eq_append_biquad(eq, BQ_PEAKING, 580 / NQ, 6, -8);
47+
eq_append_biquad(eq, BQ_HIGHSHELF, 8000 / NQ, 3, 2);
48+
for (auto _ : state) {
49+
eq_process(eq, samples.data(), frames);
50+
}
51+
eq_free(eq);
52+
state.counters["frames_per_second"] = benchmark::Counter(
53+
int64_t(state.iterations()) * frames, benchmark::Counter::kIsRate);
54+
state.counters["time_per_48k_frames"] = benchmark::Counter(
55+
int64_t(state.iterations()) * frames / 48000,
56+
benchmark::Counter::kIsRate | benchmark::Counter::kInvert);
57+
}
58+
59+
BENCHMARK_REGISTER_F(BM_Dsp, Eq)->RangeMultiplier(2)->Range(256, 8 << 10);
60+
3661
BENCHMARK_DEFINE_F(BM_Dsp, Eq2)(benchmark::State& state) {
3762
const double NQ = 44100 / 2; // nyquist frequency
3863
// eq chain

cras/src/dsp/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ cc_library(
6464
name = "eq",
6565
srcs = ["eq.c"],
6666
hdrs = ["eq.h"],
67+
visibility = ["//cras/benchmark:__pkg__"],
6768
deps = [
6869
":biquad",
6970
"@thesofproject_sof",

0 commit comments

Comments
 (0)