Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: media/base/sinc_resampler_perftest.cc

Issue 41633002: Port SincResampler's ConvolveBenchmark, as well as VectorMath's benchmarks to media_perftests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@portbus
Patch Set: Move unused constant into prepreocessor define to fix android build. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/sinc_resampler.h ('k') | media/base/sinc_resampler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/sinc_resampler_perftest.cc
diff --git a/media/base/sinc_resampler_perftest.cc b/media/base/sinc_resampler_perftest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c7e75170e6260480beec9ae80f36b91a989c275c
--- /dev/null
+++ b/media/base/sinc_resampler_perftest.cc
@@ -0,0 +1,76 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/cpu.h"
+#include "base/time/time.h"
+#include "media/base/sinc_resampler.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/perf/perf_test.h"
+
+namespace media {
+
+static const int kBenchmarkIterations = 50000000;
+
+static const double kSampleRateRatio = 192000.0 / 44100.0;
+static const double kKernelInterpolationFactor = 0.5;
+
+// Helper function to provide no input to SincResampler's Convolve benchmark.
+static void DoNothing(int frames, float* destination) {}
+
+// Define platform independent function name for Convolve* tests.
+#if defined(ARCH_CPU_X86_FAMILY)
+#define CONVOLVE_FUNC Convolve_SSE
+#elif defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON)
+#define CONVOLVE_FUNC Convolve_NEON
+#endif
+
+static void RunConvolveBenchmark(
+ SincResampler* resampler,
+ float (*convolve_fn)(const float*, const float*, const float*, double),
+ bool aligned,
+ const std::string& trace_name) {
+ base::TimeTicks start = base::TimeTicks::HighResNow();
+ for (int i = 0; i < kBenchmarkIterations; ++i) {
+ convolve_fn(resampler->get_kernel_for_testing() + (aligned ? 0 : 1),
+ resampler->get_kernel_for_testing(),
+ resampler->get_kernel_for_testing(),
+ kKernelInterpolationFactor);
+ }
+ double total_time_seconds =
+ (base::TimeTicks::HighResNow() - start).InSecondsF();
+ perf_test::PrintResult("sinc_resampler_convolve",
+ "",
+ trace_name,
+ kBenchmarkIterations / total_time_seconds,
+ "runs/s",
+ true);
+}
+
+// Benchmark for the various Convolve() methods. Make sure to build with
+// branding=Chrome so that DCHECKs are compiled out when benchmarking.
+TEST(SincResamplerPerfTest, Convolve) {
+ SincResampler resampler(kSampleRateRatio,
+ SincResampler::kDefaultRequestSize,
+ base::Bind(&DoNothing));
+
+ RunConvolveBenchmark(
+ &resampler, SincResampler::Convolve_C, true, "unoptimized_aligned");
+
+#if defined(CONVOLVE_FUNC)
+#if defined(ARCH_CPU_X86_FAMILY)
+ ASSERT_TRUE(base::CPU().has_sse());
+#endif
+ RunConvolveBenchmark(
+ &resampler, SincResampler::CONVOLVE_FUNC, true, "optimized_aligned");
+ RunConvolveBenchmark(
+ &resampler, SincResampler::CONVOLVE_FUNC, false, "optimized_unaligned");
+#endif
+}
+
+#undef CONVOLVE_FUNC
+
+} // namespace media
« no previous file with comments | « media/base/sinc_resampler.h ('k') | media/base/sinc_resampler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698