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

Unified Diff: ui/events/latency_info.cc

Issue 424833009: Draw the start of input latency using its original/ui timestamp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/latency_info.cc
diff --git a/ui/events/latency_info.cc b/ui/events/latency_info.cc
index 021b3c9c95c083cf984609dc2032e37745299102..bb4b2634212ebd844888a6542b4e08b43afa9760 100644
--- a/ui/events/latency_info.cc
+++ b/ui/events/latency_info.cc
@@ -182,9 +182,38 @@ void LatencyInfo::AddLatencyNumberWithTimestamp(LatencyComponentType component,
// Should only ever add begin component once.
CHECK_EQ(-1, trace_id);
trace_id = component_sequence_number;
- TRACE_EVENT_ASYNC_BEGIN0("benchmark",
- "InputLatency",
- TRACE_ID_DONT_MANGLE(trace_id));
+
+ // The timestamp for ASYNC_BEGIN trace event is used for drawing the
+ // beginning of the trace event in trace viewer. For better visualization,
+ // for an input event, we want to draw the beginning as when the event is
+ // originally created, e.g. the timestamp of its ORIGINAL/UI_COMPONENT,
+ // not when we actually issue the ASYNC_BEGIN trace event.
+ LatencyComponent component;
+ if (FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
+ 0,
+ &component) ||
+ FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT,
+ 0,
+ &component)) {
+ // The timestamp stored in ORIGINAL/UI_COMPONENT is using CLOCK_MONOTONIC,
+ // while TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0 expects timestamp
+ // using CLOCK_MONOTONIC or CLOCK_SYSTEM_TRACE (on CrOS). So we need to
+ // adjust the diff between in CLOCK_MONOTONIC and CLOCK_SYSTEM_TRACE.
+ // Note that the diff is drifting overtime so we can't use a static value.
+ int64 diff = base::TimeTicks::HighResNow().ToInternalValue() -
dsinclair 2014/07/29 15:35:07 Do we know how expensive these two timer calls are
Yufeng Shen (Slow to review) 2014/07/29 20:01:33 Done.
+ base::TimeTicks::NowFromSystemTraceTime().ToInternalValue();
+ TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(
+ "benchmark",
Yufeng Shen (Slow to review) 2014/07/28 23:56:31 Hey Dan, I want to confirm with you that trace eve
dsinclair 2014/07/29 15:35:06 Why not create a TRACE_EVENT_ASYNC_BEGIN_WITH_TIME
Yufeng Shen (Slow to review) 2014/07/29 20:01:33 Done.
+ "InputLatency",
+ TRACE_ID_DONT_MANGLE(trace_id),
+ static_cast<int>(base::PlatformThread::CurrentId()),
+ component.event_time.ToInternalValue() - diff);
+ } else {
+ TRACE_EVENT_ASYNC_BEGIN0("benchmark",
dsinclair 2014/07/29 15:35:06 Why not have this part of what's above and then, i
Yufeng Shen (Slow to review) 2014/07/29 20:01:33 Done.
+ "InputLatency",
+ TRACE_ID_DONT_MANGLE(trace_id));
+ }
+
TRACE_EVENT_FLOW_BEGIN0(
"input", "LatencyInfo.Flow", TRACE_ID_DONT_MANGLE(trace_id));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698