Chromium Code Reviews| Index: base/debug/task_annotator.cc |
| diff --git a/base/debug/task_annotator.cc b/base/debug/task_annotator.cc |
| index 10c563614508f6f1fe6b975468e8ec464c7e0f3b..41f6caecbad188b129b5e0ff1295713bf4061b4d 100644 |
| --- a/base/debug/task_annotator.cc |
| +++ b/base/debug/task_annotator.cc |
| @@ -8,10 +8,32 @@ |
| #include "base/debug/activity_tracker.h" |
| #include "base/debug/alias.h" |
| +#include "base/metrics/histogram_functions.h" |
| #include "base/pending_task.h" |
| #include "base/trace_event/trace_event.h" |
| #include "base/tracked_objects.h" |
| +namespace { |
| + |
| +void RecordCPUTimeUMA(tracked_objects::ThreadData* thread_data, |
| + base::TimeDelta duration) { |
| + if (!thread_data) |
| + return; |
| + |
| + if (duration.InMillisecondsF() == 0) |
| + return; |
| + |
| + if (!thread_data->task_length_recording_enabled_for_uma()) |
|
Sami
2017/07/26 20:36:38
Can we swap this before the previous 'if' since th
|
| + return; |
| + |
| + // TODO - this is slow. |
|
Sami
2017/07/26 20:36:38
TODO(tdresser)
In any case we probably can't land
tdresser
2017/07/27 19:18:05
Oops, yeah, I meant to call this out as something
Sami
2017/08/04 15:46:32
Yeah, this is pretty tough from a layering perspec
|
| + base::UmaHistogramCustomCounts( |
| + "Scheduling.TaskTime." + thread_data->sanitized_thread_name(), |
| + duration.InMicroseconds(), 1, 1000 * 1000, 50); |
| +} |
| + |
| +} // namespace |
| + |
| namespace base { |
| namespace debug { |
| @@ -59,6 +81,9 @@ void TaskAnnotator::RunTask(const char* queue_function, |
| std::move(pending_task->task).Run(); |
| stopwatch.Stop(); |
| + |
| + RecordCPUTimeUMA(stopwatch.GetThreadData(), stopwatch.RunDuration()); |
| + |
| tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking(*pending_task, |
| stopwatch); |
| } |