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/filters/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
;
23 ASSERT_TRUE(pipeline
.Start(GetTestDataFilePath(filename
),
25 PipelineIntegrationTestBase::kClockless
));
27 base::TimeTicks start
= base::TimeTicks::HighResNow();
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::HighResNow() - 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-640x360.webm",
72 "clockless_video_playback_vp8");
73 RunVideoPlaybackBenchmark("bear-320x240.webm",
74 "clockless_video_playback_vp8");
77 TEST(PipelineIntegrationPerfTest
, VP9PlaybackBenchmark
) {
78 RunVideoPlaybackBenchmark("bear-vp9.webm", "clockless_video_playback_vp9");
81 TEST(PipelineIntegrationPerfTest
, TheoraPlaybackBenchmark
) {
82 RunVideoPlaybackBenchmark("bear.ogv", "clockless_video_playback_theora");
85 #if defined(USE_PROPRIETARY_CODECS)
86 TEST(PipelineIntegrationPerfTest
, MP4PlaybackBenchmark
) {
87 RunVideoPlaybackBenchmark("bear-1280x720.mp4",
88 "clockless_video_playback_mp4");