OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/debug/trace_event.h" | 5 #include "base/debug/trace_event.h" |
6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "ui/events/latency_info.h" | 9 #include "ui/events/latency_info.h" |
10 | 10 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 it->second.event_time, | 195 it->second.event_time, |
196 it->second.event_count); | 196 it->second.event_count); |
197 } | 197 } |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 void LatencyInfo::AddLatencyNumber(LatencyComponentType component, | 201 void LatencyInfo::AddLatencyNumber(LatencyComponentType component, |
202 int64 id, | 202 int64 id, |
203 int64 component_sequence_number) { | 203 int64 component_sequence_number) { |
204 AddLatencyNumberWithTimestamp(component, id, component_sequence_number, | 204 AddLatencyNumberWithTimestamp(component, id, component_sequence_number, |
205 base::TimeTicks::HighResNow(), 1); | 205 base::TimeTicks::Now(), 1); |
206 } | 206 } |
207 | 207 |
208 void LatencyInfo::AddLatencyNumberWithTimestamp(LatencyComponentType component, | 208 void LatencyInfo::AddLatencyNumberWithTimestamp(LatencyComponentType component, |
209 int64 id, | 209 int64 id, |
210 int64 component_sequence_number, | 210 int64 component_sequence_number, |
211 base::TimeTicks time, | 211 base::TimeTicks time, |
212 uint32 event_count) { | 212 uint32 event_count) { |
213 | 213 |
214 static const unsigned char* benchmark_enabled = | 214 static const unsigned char* benchmark_enabled = |
215 TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED("benchmark"); | 215 TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED("benchmark"); |
(...skipping 16 matching lines...) Expand all Loading... |
232 &component) || | 232 &component) || |
233 FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, | 233 FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, |
234 0, | 234 0, |
235 &component)) { | 235 &component)) { |
236 // The timestamp stored in ORIGINAL/UI_COMPONENT is using clock | 236 // The timestamp stored in ORIGINAL/UI_COMPONENT is using clock |
237 // CLOCK_MONOTONIC while TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0 | 237 // CLOCK_MONOTONIC while TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0 |
238 // expects timestamp using CLOCK_MONOTONIC or CLOCK_SYSTEM_TRACE (on | 238 // expects timestamp using CLOCK_MONOTONIC or CLOCK_SYSTEM_TRACE (on |
239 // CrOS). So we need to adjust the diff between in CLOCK_MONOTONIC and | 239 // CrOS). So we need to adjust the diff between in CLOCK_MONOTONIC and |
240 // CLOCK_SYSTEM_TRACE. Note that the diff is drifting overtime so we | 240 // CLOCK_SYSTEM_TRACE. Note that the diff is drifting overtime so we |
241 // can't use a static value. | 241 // can't use a static value. |
242 int64 diff = base::TimeTicks::HighResNow().ToInternalValue() - | 242 int64 diff = base::TimeTicks::Now().ToInternalValue() - |
243 base::TimeTicks::NowFromSystemTraceTime().ToInternalValue(); | 243 base::TimeTicks::NowFromSystemTraceTime().ToInternalValue(); |
244 ts = component.event_time.ToInternalValue() - diff; | 244 ts = component.event_time.ToInternalValue() - diff; |
245 } else { | 245 } else { |
246 ts = base::TimeTicks::NowFromSystemTraceTime().ToInternalValue(); | 246 ts = base::TimeTicks::NowFromSystemTraceTime().ToInternalValue(); |
247 } | 247 } |
248 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0( | 248 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0( |
249 "benchmark", | 249 "benchmark", |
250 "InputLatency", | 250 "InputLatency", |
251 TRACE_ID_DONT_MANGLE(trace_id), | 251 TRACE_ID_DONT_MANGLE(trace_id), |
252 ts); | 252 ts); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 } | 322 } |
323 | 323 |
324 void LatencyInfo::TraceEventType(const char* event_type) { | 324 void LatencyInfo::TraceEventType(const char* event_type) { |
325 TRACE_EVENT_ASYNC_STEP_INTO0("benchmark", | 325 TRACE_EVENT_ASYNC_STEP_INTO0("benchmark", |
326 "InputLatency", | 326 "InputLatency", |
327 TRACE_ID_DONT_MANGLE(trace_id), | 327 TRACE_ID_DONT_MANGLE(trace_id), |
328 event_type); | 328 event_type); |
329 } | 329 } |
330 | 330 |
331 } // namespace ui | 331 } // namespace ui |
OLD | NEW |