diff options
author | rileya@chromium.org <rileya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-30 20:32:18 +0000 |
---|---|---|
committer | rileya@chromium.org <rileya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-30 20:32:18 +0000 |
commit | 5b6293d6395ac960aef75aa0d70932653e20e5b4 (patch) | |
tree | f0a9f3c6c1abf71d275e312fb089abe35795667d /media/base/sinc_resampler_unittest.cc | |
parent | 7280f2f1c739cdfcd0337c6e040e05799c2b3693 (diff) | |
download | chromium_src-5b6293d6395ac960aef75aa0d70932653e20e5b4.zip chromium_src-5b6293d6395ac960aef75aa0d70932653e20e5b4.tar.gz chromium_src-5b6293d6395ac960aef75aa0d70932653e20e5b4.tar.bz2 |
Port SincResampler's ConvolveBenchmark, as well as VectorMath's FMUL and FMAC benchmarks to media_perftests.
BUG=310837
Review URL: https://codereview.chromium.org/41633002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/sinc_resampler_unittest.cc')
-rw-r--r-- | media/base/sinc_resampler_unittest.cc | 77 |
1 files changed, 2 insertions, 75 deletions
diff --git a/media/base/sinc_resampler_unittest.cc b/media/base/sinc_resampler_unittest.cc index 8b89a5d..3b460a3 100644 --- a/media/base/sinc_resampler_unittest.cc +++ b/media/base/sinc_resampler_unittest.cc @@ -9,11 +9,8 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/command_line.h" #include "base/cpu.h" -#include "base/logging.h" #include "base/strings/string_number_conversions.h" -#include "base/strings/stringize_macros.h" #include "base/time/time.h" #include "build/build_config.h" #include "media/base/sinc_resampler.h" @@ -25,10 +22,6 @@ using testing::_; namespace media { static const double kSampleRateRatio = 192000.0 / 44100.0; -static const double kKernelInterpolationFactor = 0.5; - -// Command line switch for runtime adjustment of ConvolveBenchmark iterations. -static const char kConvolveIterations[] = "convolve-iterations"; // Helper class to ensure ChunkedResample() functions properly. class MockSource { @@ -125,6 +118,8 @@ TEST(SincResamplerTest, DISABLED_SetRatioBench) { // this test if other optimized methods exist, otherwise the default Convolve() // will be tested by the parameterized SincResampler tests below. #if defined(CONVOLVE_FUNC) +static const double kKernelInterpolationFactor = 0.5; + TEST(SincResamplerTest, Convolve) { #if defined(ARCH_CPU_X86_FAMILY) ASSERT_TRUE(base::CPU().has_sse()); @@ -161,74 +156,6 @@ TEST(SincResamplerTest, Convolve) { } #endif -// Benchmark for the various Convolve() methods. Make sure to build with -// branding=Chrome so that DCHECKs are compiled out when benchmarking. Original -// benchmarks were run with --convolve-iterations=50000000. -TEST(SincResamplerTest, ConvolveBenchmark) { - // Initialize a dummy resampler. - MockSource mock_source; - SincResampler resampler( - kSampleRateRatio, SincResampler::kDefaultRequestSize, - base::Bind(&MockSource::ProvideInput, base::Unretained(&mock_source))); - - // Retrieve benchmark iterations from command line. - int convolve_iterations = 10; - std::string iterations(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - kConvolveIterations)); - if (!iterations.empty()) - base::StringToInt(iterations, &convolve_iterations); - - printf("Benchmarking %d iterations:\n", convolve_iterations); - - // Benchmark Convolve_C(). - base::TimeTicks start = base::TimeTicks::HighResNow(); - for (int i = 0; i < convolve_iterations; ++i) { - resampler.Convolve_C( - resampler.kernel_storage_.get(), resampler.kernel_storage_.get(), - resampler.kernel_storage_.get(), kKernelInterpolationFactor); - } - double total_time_c_ms = - (base::TimeTicks::HighResNow() - start).InMillisecondsF(); - printf("Convolve_C took %.2fms.\n", total_time_c_ms); - -#if defined(CONVOLVE_FUNC) -#if defined(ARCH_CPU_X86_FAMILY) - ASSERT_TRUE(base::CPU().has_sse()); -#endif - - // Benchmark with unaligned input pointer. - start = base::TimeTicks::HighResNow(); - for (int j = 0; j < convolve_iterations; ++j) { - resampler.CONVOLVE_FUNC( - resampler.kernel_storage_.get() + 1, resampler.kernel_storage_.get(), - resampler.kernel_storage_.get(), kKernelInterpolationFactor); - } - double total_time_optimized_unaligned_ms = - (base::TimeTicks::HighResNow() - start).InMillisecondsF(); - printf(STRINGIZE(CONVOLVE_FUNC) " (unaligned) took %.2fms; which is %.2fx " - "faster than Convolve_C.\n", total_time_optimized_unaligned_ms, - total_time_c_ms / total_time_optimized_unaligned_ms); - - // Benchmark with aligned input pointer. - start = base::TimeTicks::HighResNow(); - for (int j = 0; j < convolve_iterations; ++j) { - resampler.CONVOLVE_FUNC( - resampler.kernel_storage_.get(), resampler.kernel_storage_.get(), - resampler.kernel_storage_.get(), kKernelInterpolationFactor); - } - double total_time_optimized_aligned_ms = - (base::TimeTicks::HighResNow() - start).InMillisecondsF(); - printf(STRINGIZE(CONVOLVE_FUNC) " (aligned) took %.2fms; which is %.2fx " - "faster than Convolve_C and %.2fx faster than " - STRINGIZE(CONVOLVE_FUNC) " (unaligned).\n", - total_time_optimized_aligned_ms, - total_time_c_ms / total_time_optimized_aligned_ms, - total_time_optimized_unaligned_ms / total_time_optimized_aligned_ms); -#endif -} - -#undef CONVOLVE_FUNC - // Fake audio source for testing the resampler. Generates a sinusoidal linear // chirp (http://en.wikipedia.org/wiki/Chirp) which can be tuned to stress the // resampler for the specific sample rate conversion being used. |