Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2447)

Unified Diff: cc/ipc/cc_param_traits_perftest.cc

Issue 2109863002: cc::CompositorFrame: Implement ParamTraits vs. StructTraits perf test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased + Renamed test Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/ipc/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/ipc/cc_param_traits_perftest.cc
diff --git a/cc/ipc/cc_param_traits_perftest.cc b/cc/ipc/cc_param_traits_perftest.cc
index 1cf40f1a3a3c199878a0f5a390bdb81ab17890de..ebc4dc2738faa790b88991f8f143a145e3e03fe6 100644
--- a/cc/ipc/cc_param_traits_perftest.cc
+++ b/cc/ipc/cc_param_traits_perftest.cc
@@ -7,18 +7,33 @@
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
#include "cc/ipc/cc_param_traits.h"
+#include "cc/ipc/compositor_frame.mojom.h"
+#include "cc/ipc/compositor_frame_metadata_struct_traits.h"
+#include "cc/ipc/compositor_frame_struct_traits.h"
+#include "cc/ipc/render_pass_struct_traits.h"
+#include "cc/ipc/selection_struct_traits.h"
+#include "cc/ipc/shared_quad_state_struct_traits.h"
+#include "cc/ipc/surface_id_struct_traits.h"
+#include "cc/ipc/transferable_resource_struct_traits.h"
#include "cc/output/compositor_frame.h"
#include "cc/quads/picture_draw_quad.h"
+#include "gpu/ipc/common/mailbox_holder_struct_traits.h"
+#include "gpu/ipc/common/mailbox_struct_traits.h"
+#include "gpu/ipc/common/sync_token_struct_traits.h"
#include "ipc/ipc_message.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_test.h"
+#include "ui/events/mojo/latency_info_struct_traits.h"
+#include "ui/gfx/geometry/mojo/geometry.mojom.h"
+#include "ui/gfx/geometry/mojo/geometry_struct_traits.h"
+#include "ui/gfx/mojo/selection_bound_struct_traits.h"
using cc::CompositorFrame;
using cc::DelegatedFrameData;
using cc::DrawQuad;
-using cc::PictureDrawQuad;
using cc::RenderPass;
using cc::SharedQuadState;
+using cc::SolidColorDrawQuad;
namespace content {
namespace {
@@ -27,10 +42,10 @@ static const int kTimeLimitMillis = 2000;
static const int kNumWarmupRuns = 20;
static const int kTimeCheckInterval = 10;
-class CCParamTraitsPerfTest : public testing::Test {
+class CCSerializationPerfTest : public testing::Test {
protected:
- static void RunTest(const std::string& test_name,
- const CompositorFrame& frame) {
+ static void RunTestParamTraits(const std::string& test_name,
+ const CompositorFrame& frame) {
for (int i = 0; i < kNumWarmupRuns; ++i) {
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
IPC::ParamTraits<CompositorFrame>::Write(&msg, frame);
@@ -40,7 +55,7 @@ class CCParamTraitsPerfTest : public testing::Test {
base::TimeTicks end =
start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis);
base::TimeDelta min_time;
- int count = 0;
+ size_t count = 0;
while (start < end) {
for (int i = 0; i < kTimeCheckInterval; ++i) {
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
@@ -55,100 +70,155 @@ class CCParamTraitsPerfTest : public testing::Test {
}
perf_test::PrintResult(
- "min_frame_serialization_time", "", test_name,
+ "ParamTraits: min_frame_serialization_time", "", test_name,
min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", true);
+ perf_test::PrintResult("ParamTraits: num runs in 2 seconds", "", test_name,
+ count, "", true);
+ }
+
+ static void RunTestStructTraits(const std::string& test_name,
+ const CompositorFrame& frame) {
+ for (int i = 0; i < kNumWarmupRuns; ++i) {
+ mojo::Array<uint8_t> data = cc::mojom::CompositorFrame::Serialize(&frame);
+ DCHECK_GT(data.size(), 0u);
+ }
+
+ base::TimeTicks start = base::TimeTicks::Now();
+ base::TimeTicks end =
+ start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis);
+ base::TimeDelta min_time;
+ size_t count = 0;
+ while (start < end) {
+ for (int i = 0; i < kTimeCheckInterval; ++i) {
+ mojo::Array<uint8_t> data =
+ cc::mojom::CompositorFrame::Serialize(&frame);
+ DCHECK_GT(data.size(), 0u);
+ ++count;
+ }
+
+ base::TimeTicks now = base::TimeTicks::Now();
+ if (now - start < min_time || min_time.is_zero())
+ min_time = now - start;
+ start = base::TimeTicks::Now();
+ }
+
+ perf_test::PrintResult(
+ "StructTraits min_frame_serialization_time", "", test_name,
+ min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", true);
+ perf_test::PrintResult("StructTraits: num runs in 2 seconds", "", test_name,
+ count, "", true);
+ }
+
+ static void RunTest(const std::string& test_name, CompositorFrame frame) {
+ RunTestStructTraits(test_name, frame);
+ RunTestParamTraits(test_name, frame);
}
};
-TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyQuads_1_4000) {
- std::unique_ptr<CompositorFrame> frame(new CompositorFrame);
+TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_4000) {
+ CompositorFrame frame;
std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
render_pass->CreateAndAppendSharedQuadState();
for (int i = 0; i < 4000; ++i) {
- PictureDrawQuad* quad =
- render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>();
- quad->shared_quad_state = render_pass->shared_quad_state_list.back();
+ const gfx::Rect bounds(100, 100, 100, 100);
+ const bool force_anti_aliasing_off = true;
yzshen1 2016/07/06 17:11:56 style nit: compile-time constants are named kLikeT
Fady Samuel 2016/07/06 17:25:47 Done.
+ SolidColorDrawQuad* quad =
+ render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
+ quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
+ SK_ColorRED, force_anti_aliasing_off);
}
- frame->delegated_frame_data.reset(new DelegatedFrameData);
- frame->delegated_frame_data->render_pass_list.push_back(
+ frame.delegated_frame_data.reset(new DelegatedFrameData);
+ frame.delegated_frame_data->render_pass_list.push_back(
std::move(render_pass));
- RunTest("DelegatedFrame_ManyQuads_1_4000", *frame);
+ RunTest("DelegatedFrame_ManyQuads_1_4000", std::move(frame));
}
-TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyQuads_1_100000) {
- std::unique_ptr<CompositorFrame> frame(new CompositorFrame);
+TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_100000) {
+ CompositorFrame frame;
std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
render_pass->CreateAndAppendSharedQuadState();
for (int i = 0; i < 100000; ++i) {
- PictureDrawQuad* quad =
- render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>();
- quad->shared_quad_state = render_pass->shared_quad_state_list.back();
+ const gfx::Rect bounds(100, 100, 100, 100);
+ const bool force_anti_aliasing_off = true;
+ SolidColorDrawQuad* quad =
+ render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
+ quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
+ SK_ColorRED, force_anti_aliasing_off);
}
- frame->delegated_frame_data.reset(new DelegatedFrameData);
- frame->delegated_frame_data->render_pass_list.push_back(
+ frame.delegated_frame_data.reset(new DelegatedFrameData);
+ frame.delegated_frame_data->render_pass_list.push_back(
std::move(render_pass));
- RunTest("DelegatedFrame_ManyQuads_1_100000", *frame);
+ RunTest("DelegatedFrame_ManyQuads_1_100000", std::move(frame));
}
-TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyQuads_4000_4000) {
- std::unique_ptr<CompositorFrame> frame(new CompositorFrame);
+TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_4000_4000) {
+ CompositorFrame frame;
std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
for (int i = 0; i < 4000; ++i) {
+ const gfx::Rect bounds(100, 100, 100, 100);
+ const bool force_anti_aliasing_off = true;
render_pass->CreateAndAppendSharedQuadState();
- PictureDrawQuad* quad =
- render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>();
- quad->shared_quad_state = render_pass->shared_quad_state_list.back();
+ SolidColorDrawQuad* quad =
+ render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
+ quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
+ SK_ColorRED, force_anti_aliasing_off);
}
- frame->delegated_frame_data.reset(new DelegatedFrameData);
- frame->delegated_frame_data->render_pass_list.push_back(
+ frame.delegated_frame_data.reset(new DelegatedFrameData);
+ frame.delegated_frame_data->render_pass_list.push_back(
std::move(render_pass));
- RunTest("DelegatedFrame_ManyQuads_4000_4000", *frame);
+ RunTest("DelegatedFrame_ManyQuads_4000_4000", std::move(frame));
}
-TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyQuads_100000_100000) {
- std::unique_ptr<CompositorFrame> frame(new CompositorFrame);
+TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_100000_100000) {
+ CompositorFrame frame;
std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
for (int i = 0; i < 100000; ++i) {
render_pass->CreateAndAppendSharedQuadState();
- PictureDrawQuad* quad =
- render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>();
- quad->shared_quad_state = render_pass->shared_quad_state_list.back();
+ const gfx::Rect bounds(100, 100, 100, 100);
+ const bool force_anti_aliasing_off = true;
+ SolidColorDrawQuad* quad =
+ render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
+ quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
+ SK_ColorRED, force_anti_aliasing_off);
}
- frame->delegated_frame_data.reset(new DelegatedFrameData);
- frame->delegated_frame_data->render_pass_list.push_back(
+ frame.delegated_frame_data.reset(new DelegatedFrameData);
+ frame.delegated_frame_data->render_pass_list.push_back(
std::move(render_pass));
- RunTest("DelegatedFrame_ManyQuads_100000_100000", *frame);
+ RunTest("DelegatedFrame_ManyQuads_100000_100000", std::move(frame));
}
-TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyRenderPasses_10000_100) {
- std::unique_ptr<CompositorFrame> frame(new CompositorFrame);
- frame->delegated_frame_data.reset(new DelegatedFrameData);
+TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyRenderPasses_10000_100) {
+ CompositorFrame frame;
+ frame.delegated_frame_data.reset(new DelegatedFrameData);
for (int i = 0; i < 1000; ++i) {
std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
for (int j = 0; j < 100; ++j) {
render_pass->CreateAndAppendSharedQuadState();
- PictureDrawQuad* quad =
- render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>();
- quad->shared_quad_state = render_pass->shared_quad_state_list.back();
+ const gfx::Rect bounds(100, 100, 100, 100);
+ const bool force_anti_aliasing_off = true;
+ SolidColorDrawQuad* quad =
+ render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
+ quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
+ SK_ColorRED, force_anti_aliasing_off);
}
- frame->delegated_frame_data->render_pass_list.push_back(
+ frame.delegated_frame_data->render_pass_list.push_back(
std::move(render_pass));
}
- RunTest("DelegatedFrame_ManyRenderPasses_10000_100", *frame);
+ RunTest("DelegatedFrame_ManyRenderPasses_10000_100", std::move(frame));
}
} // namespace
« no previous file with comments | « cc/ipc/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698