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

Side by Side 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: Address comments in vector_math_perftest. Created 7 years, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "base/bind_helpers.h"
7 #include "base/cpu.h"
8 #include "base/time/time.h"
9 #include "media/base/sinc_resampler.h"
10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/perf/perf_test.h"
13
14 namespace media {
15
16 static const int kBenchmarkIterations = 50000000;
17
18 static const double kSampleRateRatio = 192000.0 / 44100.0;
19 static const double kKernelInterpolationFactor = 0.5;
20
21 // Helper function to ensure ChunkedResample() functions properly.
scherkus (not reviewing) 2013/10/29 02:16:51 this comment refers to a unit test: https://code.g
22 static void DoNothing(int frames, float* destination) {}
23
24 // Define platform independent function name for Convolve* tests.
25 #if defined(ARCH_CPU_X86_FAMILY)
26 #define CONVOLVE_FUNC Convolve_SSE
27 #elif defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON)
28 #define CONVOLVE_FUNC Convolve_NEON
29 #endif
30
31 static void RunConvolveBenchmark(
32 SincResampler* resampler,
33 float (*convolve_fn)(const float*, const float*, const float*, double),
34 bool aligned,
35 const std::string& trace_name) {
36 base::TimeTicks start = base::TimeTicks::HighResNow();
37 for (int i = 0; i < kBenchmarkIterations; ++i) {
38 convolve_fn(resampler.get_kernel_for_testing() + (aligned ? 0 : 1),
scherkus (not reviewing) 2013/10/29 02:16:51 shouldn't these resampler calls use -> notation?
39 resampler.get_kernel_for_testing(),
40 resampler.get_kernel_for_testing(),
41 kKernelInterpolationFactor);
42 }
43 double total_time_seconds =
44 (base::TimeTicks::HighResNow() - start).InSecondsF();
45 perf_test::PrintResult("sinc_resampler_convolve",
46 "",
47 trace_name,
48 kBenchmarkIterations / total_time_seconds,
49 "runs/s",
50 true);
51 }
52
53 // Benchmark for the various Convolve() methods. Make sure to build with
54 // branding=Chrome so that DCHECKs are compiled out when benchmarking.
55 TEST(SincResamplerPerfTest, Convolve) {
56 // Initialize a dummy resampler.
scherkus (not reviewing) 2013/10/29 02:16:51 comment is useless -- remove
57 SincResampler resampler(kSampleRateRatio,
58 SincResampler::kDefaultRequestSize,
59 base::Bind(&DoNothing));
60
61 RunConvolveBenchmark(
62 &resampler, SincResampler::Convolve_C, true, "unoptimized_aligned");
63
64 #if defined(CONVOLVE_FUNC)
65 #if defined(ARCH_CPU_X86_FAMILY)
66 ASSERT_TRUE(base::CPU().has_sse());
67 #endif
68 RunConvolveBenchmark(
69 &resampler, SincResampler::CONVOLVE_FUNC, true, "optimized_aligned");
70 RunConvolveBenchmark(
71 &resampler, SincResampler::CONVOLVE_FUNC, false, "optimized_unaligned");
72 #endif
73 }
74
75 #undef CONVOLVE_FUNC
76
77 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698