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

Side by Side Diff: base/debug/task_annotator.cc

Issue 2398263002: Measure how many tasks are cancelled in MessageLoop.
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | base/message_loop/message_loop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/task_annotator.h" 5 #include "base/debug/task_annotator.h"
6 6
7 #include "base/debug/activity_tracker.h" 7 #include "base/debug/activity_tracker.h"
8 #include "base/debug/alias.h" 8 #include "base/debug/alias.h"
9 #include "base/metrics/histogram_macros.h"
9 #include "base/pending_task.h" 10 #include "base/pending_task.h"
10 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
11 #include "base/tracked_objects.h" 12 #include "base/tracked_objects.h"
12 13
13 namespace base { 14 namespace base {
14 namespace debug { 15 namespace debug {
15 16
16 TaskAnnotator::TaskAnnotator() { 17 TaskAnnotator::TaskAnnotator() {
17 } 18 }
18 19
19 TaskAnnotator::~TaskAnnotator() { 20 TaskAnnotator::~TaskAnnotator() {
20 } 21 }
21 22
22 void TaskAnnotator::DidQueueTask(const char* queue_function, 23 void TaskAnnotator::DidQueueTask(const char* queue_function,
23 const PendingTask& pending_task) { 24 const PendingTask& pending_task) {
24 TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), 25 TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"),
25 queue_function, 26 queue_function,
26 TRACE_ID_MANGLE(GetTaskTraceID(pending_task)), 27 TRACE_ID_MANGLE(GetTaskTraceID(pending_task)),
27 TRACE_EVENT_FLAG_FLOW_OUT); 28 TRACE_EVENT_FLAG_FLOW_OUT);
28 } 29 }
29 30
30 void TaskAnnotator::RunTask(const char* queue_function, 31 void TaskAnnotator::RunTask(const char* queue_function,
31 const PendingTask& pending_task) { 32 const PendingTask& pending_task) {
33 UMA_HISTOGRAM_BOOLEAN("TaskRunner.DispatchedTaskIsCancelled",
34 pending_task.task.IsCancelled());
35
32 ScopedTaskRunActivity task_activity(pending_task); 36 ScopedTaskRunActivity task_activity(pending_task);
33 37
34 tracked_objects::TaskStopwatch stopwatch; 38 tracked_objects::TaskStopwatch stopwatch;
35 stopwatch.Start(); 39 stopwatch.Start();
36 tracked_objects::Duration queue_duration = 40 tracked_objects::Duration queue_duration =
37 stopwatch.StartTime() - pending_task.EffectiveTimePosted(); 41 stopwatch.StartTime() - pending_task.EffectiveTimePosted();
38 42
39 TRACE_EVENT_WITH_FLOW1(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), 43 TRACE_EVENT_WITH_FLOW1(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"),
40 queue_function, 44 queue_function,
41 TRACE_ID_MANGLE(GetTaskTraceID(pending_task)), 45 TRACE_ID_MANGLE(GetTaskTraceID(pending_task)),
(...skipping 17 matching lines...) Expand all
59 } 63 }
60 64
61 uint64_t TaskAnnotator::GetTaskTraceID(const PendingTask& task) const { 65 uint64_t TaskAnnotator::GetTaskTraceID(const PendingTask& task) const {
62 return (static_cast<uint64_t>(task.sequence_num) << 32) | 66 return (static_cast<uint64_t>(task.sequence_num) << 32) |
63 ((static_cast<uint64_t>(reinterpret_cast<intptr_t>(this)) << 32) >> 67 ((static_cast<uint64_t>(reinterpret_cast<intptr_t>(this)) << 32) >>
64 32); 68 32);
65 } 69 }
66 70
67 } // namespace debug 71 } // namespace debug
68 } // namespace base 72 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/message_loop/message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698