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.
5 #include "media/base/test_data_util.h"
6 #include "media/test/pipeline_integration_test_base.h"
7 #include "testing/perf/perf_test.h"
11 static const int kBenchmarkIterationsAudio
= 200;
12 static const int kBenchmarkIterationsVideo
= 20;
14 static void RunPlaybackBenchmark(const std::string
& filename
,
15 const std::string
& name
,
18 double time_seconds
= 0.0;
20 for (int i
= 0; i
< iterations
; ++i
) {
21 PipelineIntegrationTestBase pipeline
;
25 pipeline
.Start(filename
, PipelineIntegrationTestBase::kClockless
));
27 base::TimeTicks start
= base::TimeTicks::Now();
30 ASSERT_TRUE(pipeline
.WaitUntilOnEnded());
32 // Call Stop() to ensure that the rendering is complete.
36 time_seconds
+= pipeline
.GetAudioTime().InSecondsF();
38 time_seconds
+= (base::TimeTicks::Now() - start
).InSecondsF();
42 perf_test::PrintResult(name
,
45 iterations
/ time_seconds
,
50 static void RunVideoPlaybackBenchmark(const std::string
& filename
,
51 const std::string name
) {
52 RunPlaybackBenchmark(filename
, name
, kBenchmarkIterationsVideo
, false);
55 static void RunAudioPlaybackBenchmark(const std::string
& filename
,
56 const std::string
& name
) {
57 RunPlaybackBenchmark(filename
, name
, kBenchmarkIterationsAudio
, true);
60 TEST(PipelineIntegrationPerfTest
, AudioPlaybackBenchmark
) {
61 RunAudioPlaybackBenchmark("sfx_f32le.wav", "clockless_playback");
62 RunAudioPlaybackBenchmark("sfx_s24le.wav", "clockless_playback");
63 RunAudioPlaybackBenchmark("sfx_s16le.wav", "clockless_playback");
64 RunAudioPlaybackBenchmark("sfx_u8.wav", "clockless_playback");
65 #if defined(USE_PROPRIETARY_CODECS)
66 RunAudioPlaybackBenchmark("sfx.mp3", "clockless_playback");
70 TEST(PipelineIntegrationPerfTest
, VP8PlaybackBenchmark
) {
71 RunVideoPlaybackBenchmark("bear_silent.webm", "clockless_video_playback_vp8");
74 TEST(PipelineIntegrationPerfTest
, VP9PlaybackBenchmark
) {
75 RunVideoPlaybackBenchmark("bear-vp9.webm", "clockless_video_playback_vp9");
78 TEST(PipelineIntegrationPerfTest
, TheoraPlaybackBenchmark
) {
79 RunVideoPlaybackBenchmark("bear_silent.ogv",
80 "clockless_video_playback_theora");
83 #if defined(USE_PROPRIETARY_CODECS)
84 TEST(PipelineIntegrationPerfTest
, MP4PlaybackBenchmark
) {
85 RunVideoPlaybackBenchmark("bear_silent.mp4", "clockless_video_playback_mp4");