10f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 20f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 30f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// found in the LICENSE file. 40f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 50f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#include "media/base/test_data_util.h" 60f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#include "media/filters/pipeline_integration_test_base.h" 70f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#include "testing/perf/perf_test.h" 80f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 90f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)namespace media { 100f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 11a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)static const int kBenchmarkIterationsAudio = 200; 12a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)static const int kBenchmarkIterationsVideo = 20; 130f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 14a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)static void RunPlaybackBenchmark(const std::string& filename, 15a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const std::string& name, 16a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) int iterations, 17a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) bool audio_only) { 180f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) double time_seconds = 0.0; 190f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 20a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) for (int i = 0; i < iterations; ++i) { 210f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) PipelineIntegrationTestBase pipeline; 220f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 230f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) ASSERT_TRUE(pipeline.Start(GetTestDataFilePath(filename), 240f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) PIPELINE_OK, 250f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) PipelineIntegrationTestBase::kClockless)); 260f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 27a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::TimeTicks start = base::TimeTicks::HighResNow(); 280f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) pipeline.Play(); 290f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 300f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) ASSERT_TRUE(pipeline.WaitUntilOnEnded()); 310f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 320f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) // Call Stop() to ensure that the rendering is complete. 330f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) pipeline.Stop(); 34a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 35a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) if (audio_only) { 36a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) time_seconds += pipeline.GetAudioTime().InSecondsF(); 37a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } else { 38a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) time_seconds += (base::TimeTicks::HighResNow() - start).InSecondsF(); 39a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 400f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) } 410f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 42a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) perf_test::PrintResult(name, 430f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) "", 440f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) filename, 45a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) iterations / time_seconds, 460f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) "runs/s", 470f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) true); 480f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)} 490f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 50a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)static void RunVideoPlaybackBenchmark(const std::string& filename, 51a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const std::string name) { 52a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) RunPlaybackBenchmark(filename, name, kBenchmarkIterationsVideo, false); 53a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 54a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 55a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)static void RunAudioPlaybackBenchmark(const std::string& filename, 56a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const std::string& name) { 57a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) RunPlaybackBenchmark(filename, name, kBenchmarkIterationsAudio, true); 58a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 59a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 600f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)TEST(PipelineIntegrationPerfTest, AudioPlaybackBenchmark) { 61a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) RunAudioPlaybackBenchmark("sfx_f32le.wav", "clockless_playback"); 62a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) RunAudioPlaybackBenchmark("sfx_s24le.wav", "clockless_playback"); 63a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) RunAudioPlaybackBenchmark("sfx_s16le.wav", "clockless_playback"); 64a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) RunAudioPlaybackBenchmark("sfx_u8.wav", "clockless_playback"); 65a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#if defined(USE_PROPRIETARY_CODECS) 66a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) RunAudioPlaybackBenchmark("sfx.mp3", "clockless_playback"); 67a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#endif 68a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 69a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 70a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)TEST(PipelineIntegrationPerfTest, VP8PlaybackBenchmark) { 711320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci RunVideoPlaybackBenchmark("bear_silent.webm", "clockless_video_playback_vp8"); 72a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 73a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 74a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)TEST(PipelineIntegrationPerfTest, VP9PlaybackBenchmark) { 75a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) RunVideoPlaybackBenchmark("bear-vp9.webm", "clockless_video_playback_vp9"); 76a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 77a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 78a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)TEST(PipelineIntegrationPerfTest, TheoraPlaybackBenchmark) { 791320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci RunVideoPlaybackBenchmark("bear_silent.ogv", 801320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci "clockless_video_playback_theora"); 81a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 82a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 83a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#if defined(USE_PROPRIETARY_CODECS) 84a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)TEST(PipelineIntegrationPerfTest, MP4PlaybackBenchmark) { 851320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci RunVideoPlaybackBenchmark("bear_silent.mp4", "clockless_video_playback_mp4"); 860f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)} 87a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#endif 880f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 890f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)} // namespace media 90