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

Side by Side Diff: ui/events/event.cc

Issue 1829973002: Cache pointers to histograms for recording event times. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/events/event.h" 5 #include "ui/events/event.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #if defined(USE_X11) 9 #if defined(USE_X11)
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 phase_(EP_PREDISPATCH), 305 phase_(EP_PREDISPATCH),
306 result_(ER_UNHANDLED), 306 result_(ER_UNHANDLED),
307 source_device_id_(ED_UNKNOWN_DEVICE) { 307 source_device_id_(ED_UNKNOWN_DEVICE) {
308 base::TimeDelta delta = EventTimeForNow() - time_stamp_; 308 base::TimeDelta delta = EventTimeForNow() - time_stamp_;
309 if (type_ < ET_LAST) 309 if (type_ < ET_LAST)
310 name_ = EventTypeName(type_); 310 name_ = EventTypeName(type_);
311 base::HistogramBase::Sample delta_sample = 311 base::HistogramBase::Sample delta_sample =
312 static_cast<base::HistogramBase::Sample>(delta.InMicroseconds()); 312 static_cast<base::HistogramBase::Sample>(delta.InMicroseconds());
313 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser", delta_sample, 1, 1000000, 313 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser", delta_sample, 1, 1000000,
314 100); 314 100);
315 std::string name_for_event = 315
316 base::StringPrintf("Event.Latency.Browser.%s", name_.c_str()); 316 // Though it seems inefficient to generate the string twice, the first
317 base::HistogramBase* counter_for_type = 317 // instance will be used only for DCHECK builds and the second won't be
318 // executed at all if the histogram was previously accessed here.
319 STATIC_HISTOGRAM_POINTER_GROUP(
320 base::StringPrintf("Event.Latency.Browser.%s", name_.c_str()),
321 type_, ET_LAST, Add(delta_sample),
318 base::Histogram::FactoryGet( 322 base::Histogram::FactoryGet(
319 name_for_event, 323 base::StringPrintf("Event.Latency.Browser.%s", name_.c_str()),
320 1, 324 1, 1000000, 100,
321 1000000, 325 base::HistogramBase::kUmaTargetedHistogramFlag));
322 100,
323 base::HistogramBase::kUmaTargetedHistogramFlag);
324 counter_for_type->Add(delta_sample);
325 326
326 #if defined(USE_X11) 327 #if defined(USE_X11)
327 if (native_event->type == GenericEvent) { 328 if (native_event->type == GenericEvent) {
328 XIDeviceEvent* xiev = 329 XIDeviceEvent* xiev =
329 static_cast<XIDeviceEvent*>(native_event->xcookie.data); 330 static_cast<XIDeviceEvent*>(native_event->xcookie.data);
330 source_device_id_ = xiev->sourceid; 331 source_device_id_ = xiev->sourceid;
331 } 332 }
332 #endif 333 #endif
333 #if defined(USE_OZONE) 334 #if defined(USE_OZONE)
334 source_device_id_ = 335 source_device_id_ =
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 gfx::PointF(x, y), 1148 gfx::PointF(x, y),
1148 time_stamp, 1149 time_stamp,
1149 flags | EF_FROM_TOUCH), 1150 flags | EF_FROM_TOUCH),
1150 details_(details) { 1151 details_(details) {
1151 } 1152 }
1152 1153
1153 GestureEvent::~GestureEvent() { 1154 GestureEvent::~GestureEvent() {
1154 } 1155 }
1155 1156
1156 } // namespace ui 1157 } // namespace ui
OLDNEW
« base/metrics/histogram_macros.h ('K') | « base/metrics/histogram_macros.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698