html_viewer: Correctly set focus to WebView.
[chromium-blink-merge.git] / media / test / pipeline_integration_perftest.cc
blobe09de39ee8fead784cd577c98655aa45b67539a3
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"
9 namespace media {
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,
16 int iterations,
17 bool audio_only) {
18 double time_seconds = 0.0;
20 for (int i = 0; i < iterations; ++i) {
21 PipelineIntegrationTestBase pipeline;
23 ASSERT_EQ(
24 PIPELINE_OK,
25 pipeline.Start(filename, PipelineIntegrationTestBase::kClockless));
27 base::TimeTicks start = base::TimeTicks::Now();
28 pipeline.Play();
30 ASSERT_TRUE(pipeline.WaitUntilOnEnded());
32 // Call Stop() to ensure that the rendering is complete.
33 pipeline.Stop();
35 if (audio_only) {
36 time_seconds += pipeline.GetAudioTime().InSecondsF();
37 } else {
38 time_seconds += (base::TimeTicks::Now() - start).InSecondsF();
42 perf_test::PrintResult(name,
43 "",
44 filename,
45 iterations / time_seconds,
46 "runs/s",
47 true);
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");
67 #endif
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");
87 #endif
89 } // namespace media