Commit 7855fabe authored by khmel@chromium.org's avatar khmel@chromium.org Committed by Commit Bot

arc: Build input tracing model

This build input tracing model from generic model.

TEST=Locally, unit test
BUG=b/132709527

Change-Id: Id7997001bf87548f9de04df85a06e2042d5a9e31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1640702
Commit-Queue: Yury Khmel <khmel@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#669850}
parent 1ef80741
......@@ -81,6 +81,12 @@ class ArcTracingGraphicsModel {
// Custom event.
kCustomEvent = 600,
// Input events
kInputEventCreated = 700, // 700
kInputEventWaylandDispatched, // 701
kInputEventDeliverStart, // 702
kInputEventDeliverEnd, // 703
};
struct BufferEvent {
......@@ -170,9 +176,15 @@ class ArcTracingGraphicsModel {
const EventsContainer& chrome_top_level() const { return chrome_top_level_; }
const EventsContainer& input() const { return input_; }
ArcSystemModel& system_model() { return system_model_; }
const ArcSystemModel& system_model() const { return system_model_; }
void set_skip_structure_validation_for_testing() {
skip_structure_validation_for_testing_ = true;
}
private:
// Normalizes timestamp for all events by subtracting the timestamp of the
// earliest event.
......@@ -194,12 +206,15 @@ class ArcTracingGraphicsModel {
// To avoid overlapping events are stored interlaced.
EventsContainer chrome_top_level_;
EventsContainer android_top_level_;
EventsContainer input_;
// Total duration of this model.
uint32_t duration_ = 0;
// Map Chrome buffer id to task id.
std::map<std::string, int> chrome_buffer_id_to_task_id_;
// CPU event model.
ArcSystemModel system_model_;
// Allows to have model incomplete for testing.
bool skip_structure_validation_for_testing_ = false;
DISALLOW_COPY_AND_ASSIGN(ArcTracingGraphicsModel);
};
......
......@@ -602,4 +602,63 @@ TEST_F(ArcTracingModelTest, AsynchronousSystemEvents) {
EXPECT_EQ(1400000UL, group2[1]->GetTimestamp());
}
TEST_F(ArcTracingModelTest, InputEvents) {
base::FilePath base_path;
base::PathService::Get(chrome::DIR_TEST_DATA, &base_path);
const base::FilePath tracing_path =
base_path.Append("arc_graphics_tracing").Append("trace_input.dat.gz");
std::string tracing_data_compressed;
ASSERT_TRUE(base::ReadFileToString(tracing_path, &tracing_data_compressed));
std::string tracing_data;
ASSERT_TRUE(
compression::GzipUncompress(tracing_data_compressed, &tracing_data));
ArcTracingModel model;
ASSERT_TRUE(model.Build(tracing_data));
ArcTracingGraphicsModel graphics_model;
graphics_model.set_skip_structure_validation_for_testing();
ASSERT_TRUE(graphics_model.Build(model));
const std::vector<GraphicsEvents>& buffers =
graphics_model.input().buffer_events();
ASSERT_TRUE(buffers.size());
for (const GraphicsEvents& buffer : buffers) {
ASSERT_FALSE(buffer.empty());
uint64_t last_timestamp = buffer[0].timestamp;
GraphicsEventType last_type = buffer[0].type;
EXPECT_EQ(GraphicsEventType::kInputEventCreated, last_type);
for (size_t i = 1; i < buffer.size(); ++i) {
const uint64_t timestamp = buffer[i].timestamp;
const GraphicsEventType type = buffer[i].type;
EXPECT_GE(timestamp, last_timestamp);
// One input sequence may contain multiple input events.
switch (last_type) {
case GraphicsEventType::kInputEventCreated:
case GraphicsEventType::kInputEventWaylandDispatched:
EXPECT_TRUE(type == GraphicsEventType::kInputEventCreated ||
type == GraphicsEventType::kInputEventWaylandDispatched ||
type == GraphicsEventType::kInputEventDeliverStart);
break;
case GraphicsEventType::kInputEventDeliverStart:
EXPECT_EQ(GraphicsEventType::kInputEventDeliverEnd, type);
break;
case GraphicsEventType::kInputEventDeliverEnd:
EXPECT_EQ(GraphicsEventType::kInputEventCreated, type);
break;
default:
NOTREACHED();
}
last_timestamp = timestamp;
last_type = type;
}
EXPECT_EQ(GraphicsEventType::kInputEventDeliverEnd, last_type);
}
}
} // namespace arc
......@@ -373,7 +373,7 @@ void ArcGraphicsTracingHandler::StartTracing() {
base::trace_event::TraceConfig config(
"-*,exo,viz,toplevel,gpu,cc,blink,disabled-by-default-android "
"gfx,disabled-by-default-android hal",
"gfx,disabled-by-default-android hal,disabled-by-default-android view",
base::trace_event::RECORD_CONTINUOUSLY);
config.EnableSystrace();
tracing_active_ = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment