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

Unified Diff: base/debug/task_annotator.cc

Issue 2973543002: Record task durations on Renderer Main & Compositor threads.
Patch Set: Fix layering issues. Created 3 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 | base/debug/task_annotator_unittest.cc » ('j') | base/tracked_objects.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | base/debug/task_annotator_unittest.cc » ('j') | base/tracked_objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698