Remove implementations of WebMediaPlayer::supportsFullscreen()
[chromium-blink-merge.git] / content / common / cc_messages_perftest.cc
blob87aa2e89e15e11ac7ca4561623eb9b33fcf00cc5
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 "content/common/cc_messages.h"
7 #include "base/test/launcher/unit_test_launcher.h"
8 #include "base/test/test_suite.h"
9 #include "cc/output/compositor_frame.h"
10 #include "ipc/ipc_message.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/perf/perf_test.h"
14 using cc::CompositorFrame;
15 using cc::DelegatedFrameData;
16 using cc::DrawQuad;
17 using cc::PictureDrawQuad;
18 using cc::RenderPass;
19 using cc::SharedQuadState;
21 namespace content {
22 namespace {
24 static const int kTimeLimitMillis = 2000;
25 static const int kNumWarmupRuns = 20;
26 static const int kTimeCheckInterval = 10;
28 class CCMessagesPerfTest : public testing::Test {
29 protected:
30 static void RunTest(std::string test_name, const CompositorFrame& frame) {
31 for (int i = 0; i < kNumWarmupRuns; ++i) {
32 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
33 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame);
36 base::TimeTicks start = base::TimeTicks::HighResNow();
37 base::TimeTicks end =
38 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis);
39 base::TimeDelta min_time;
40 int count = 0;
41 while (start < end) {
42 for (int i = 0; i < kTimeCheckInterval; ++i) {
43 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
44 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame);
45 ++count;
48 base::TimeTicks now = base::TimeTicks::HighResNow();
49 if (now - start < min_time || min_time == base::TimeDelta())
50 min_time = now - start;
51 start = base::TimeTicks::HighResNow();
54 perf_test::PrintResult(
55 "min_frame_serialization_time",
56 "",
57 test_name,
58 min_time.InMillisecondsF() / kTimeCheckInterval * 1000,
59 "us",
60 true);
64 TEST_F(CCMessagesPerfTest, DelegatedFrame_ManyQuads_1_4000) {
65 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
67 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
68 render_pass->shared_quad_state_list.push_back(SharedQuadState::Create());
69 for (int i = 0; i < 4000; ++i) {
70 render_pass->quad_list.push_back(
71 PictureDrawQuad::Create().PassAs<DrawQuad>());
72 render_pass->quad_list.back()->shared_quad_state =
73 render_pass->shared_quad_state_list.back();
76 frame->delegated_frame_data.reset(new DelegatedFrameData);
77 frame->delegated_frame_data->render_pass_list.push_back(render_pass.Pass());
79 RunTest("DelegatedFrame_ManyQuads_1_4000", *frame);
82 TEST_F(CCMessagesPerfTest, DelegatedFrame_ManyQuads_1_100000) {
83 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
85 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
86 render_pass->shared_quad_state_list.push_back(SharedQuadState::Create());
87 for (int i = 0; i < 100000; ++i) {
88 render_pass->quad_list.push_back(
89 PictureDrawQuad::Create().PassAs<DrawQuad>());
90 render_pass->quad_list.back()->shared_quad_state =
91 render_pass->shared_quad_state_list.back();
94 frame->delegated_frame_data.reset(new DelegatedFrameData);
95 frame->delegated_frame_data->render_pass_list.push_back(render_pass.Pass());
97 RunTest("DelegatedFrame_ManyQuads_1_100000", *frame);
100 TEST_F(CCMessagesPerfTest, DelegatedFrame_ManyQuads_4000_4000) {
101 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
103 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
104 for (int i = 0; i < 4000; ++i) {
105 render_pass->shared_quad_state_list.push_back(SharedQuadState::Create());
106 render_pass->quad_list.push_back(
107 PictureDrawQuad::Create().PassAs<DrawQuad>());
108 render_pass->quad_list.back()->shared_quad_state =
109 render_pass->shared_quad_state_list.back();
112 frame->delegated_frame_data.reset(new DelegatedFrameData);
113 frame->delegated_frame_data->render_pass_list.push_back(render_pass.Pass());
115 RunTest("DelegatedFrame_ManyQuads_4000_4000", *frame);
118 TEST_F(CCMessagesPerfTest, DelegatedFrame_ManyQuads_100000_100000) {
119 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
121 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
122 for (int i = 0; i < 100000; ++i) {
123 render_pass->shared_quad_state_list.push_back(SharedQuadState::Create());
124 render_pass->quad_list.push_back(
125 PictureDrawQuad::Create().PassAs<DrawQuad>());
126 render_pass->quad_list.back()->shared_quad_state =
127 render_pass->shared_quad_state_list.back();
130 frame->delegated_frame_data.reset(new DelegatedFrameData);
131 frame->delegated_frame_data->render_pass_list.push_back(render_pass.Pass());
133 RunTest("DelegatedFrame_ManyQuads_100000_100000", *frame);
136 TEST_F(CCMessagesPerfTest,
137 DelegatedFrame_ManyRenderPasses_10000_100) {
138 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
139 frame->delegated_frame_data.reset(new DelegatedFrameData);
141 for (int i = 0; i < 1000; ++i) {
142 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
143 for (int j = 0; j < 100; ++j) {
144 render_pass->shared_quad_state_list.push_back(SharedQuadState::Create());
145 render_pass->quad_list.push_back(
146 PictureDrawQuad::Create().PassAs<DrawQuad>());
147 render_pass->quad_list.back()->shared_quad_state =
148 render_pass->shared_quad_state_list.back();
150 frame->delegated_frame_data->render_pass_list.push_back(render_pass.Pass());
153 RunTest("DelegatedFrame_ManyRenderPasses_10000_100", *frame);
156 } // namespace
157 } // namespace content