OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "media/base/sinc_resampler.h" | 8 #include "media/base/sinc_resampler.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #define CONVOLVE_FUNC Convolve_SSE | 25 #define CONVOLVE_FUNC Convolve_SSE |
26 #elif defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) | 26 #elif defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) |
27 #define CONVOLVE_FUNC Convolve_NEON | 27 #define CONVOLVE_FUNC Convolve_NEON |
28 #endif | 28 #endif |
29 | 29 |
30 static void RunConvolveBenchmark( | 30 static void RunConvolveBenchmark( |
31 SincResampler* resampler, | 31 SincResampler* resampler, |
32 float (*convolve_fn)(const float*, const float*, const float*, double), | 32 float (*convolve_fn)(const float*, const float*, const float*, double), |
33 bool aligned, | 33 bool aligned, |
34 const std::string& trace_name) { | 34 const std::string& trace_name) { |
35 base::TimeTicks start = base::TimeTicks::HighResNow(); | 35 base::TimeTicks start = base::TimeTicks::Now(); |
36 for (int i = 0; i < kBenchmarkIterations; ++i) { | 36 for (int i = 0; i < kBenchmarkIterations; ++i) { |
37 convolve_fn(resampler->get_kernel_for_testing() + (aligned ? 0 : 1), | 37 convolve_fn(resampler->get_kernel_for_testing() + (aligned ? 0 : 1), |
38 resampler->get_kernel_for_testing(), | 38 resampler->get_kernel_for_testing(), |
39 resampler->get_kernel_for_testing(), | 39 resampler->get_kernel_for_testing(), |
40 kKernelInterpolationFactor); | 40 kKernelInterpolationFactor); |
41 } | 41 } |
42 double total_time_milliseconds = | 42 double total_time_milliseconds = |
43 (base::TimeTicks::HighResNow() - start).InMillisecondsF(); | 43 (base::TimeTicks::Now() - start).InMillisecondsF(); |
44 perf_test::PrintResult("sinc_resampler_convolve", | 44 perf_test::PrintResult("sinc_resampler_convolve", |
45 "", | 45 "", |
46 trace_name, | 46 trace_name, |
47 kBenchmarkIterations / total_time_milliseconds, | 47 kBenchmarkIterations / total_time_milliseconds, |
48 "runs/ms", | 48 "runs/ms", |
49 true); | 49 true); |
50 } | 50 } |
51 | 51 |
52 // Benchmark for the various Convolve() methods. Make sure to build with | 52 // Benchmark for the various Convolve() methods. Make sure to build with |
53 // branding=Chrome so that DCHECKs are compiled out when benchmarking. | 53 // branding=Chrome so that DCHECKs are compiled out when benchmarking. |
54 TEST(SincResamplerPerfTest, Convolve) { | 54 TEST(SincResamplerPerfTest, Convolve) { |
55 SincResampler resampler(kSampleRateRatio, | 55 SincResampler resampler(kSampleRateRatio, |
56 SincResampler::kDefaultRequestSize, | 56 SincResampler::kDefaultRequestSize, |
57 base::Bind(&DoNothing)); | 57 base::Bind(&DoNothing)); |
58 | 58 |
59 RunConvolveBenchmark( | 59 RunConvolveBenchmark( |
60 &resampler, SincResampler::Convolve_C, true, "unoptimized_aligned"); | 60 &resampler, SincResampler::Convolve_C, true, "unoptimized_aligned"); |
61 | 61 |
62 #if defined(CONVOLVE_FUNC) | 62 #if defined(CONVOLVE_FUNC) |
63 RunConvolveBenchmark( | 63 RunConvolveBenchmark( |
64 &resampler, SincResampler::CONVOLVE_FUNC, true, "optimized_aligned"); | 64 &resampler, SincResampler::CONVOLVE_FUNC, true, "optimized_aligned"); |
65 RunConvolveBenchmark( | 65 RunConvolveBenchmark( |
66 &resampler, SincResampler::CONVOLVE_FUNC, false, "optimized_unaligned"); | 66 &resampler, SincResampler::CONVOLVE_FUNC, false, "optimized_unaligned"); |
67 #endif | 67 #endif |
68 } | 68 } |
69 | 69 |
70 #undef CONVOLVE_FUNC | 70 #undef CONVOLVE_FUNC |
71 | 71 |
72 } // namespace media | 72 } // namespace media |
OLD | NEW |