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

Unified Diff: base/tracked_objects.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
Index: base/tracked_objects.cc
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc
index ad93225fa9c39402e555ce08373952fe17c86fc2..f3e5f5bdc20de21b04cbd2e7e9581bff06d9987b 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -523,7 +523,8 @@ ThreadData::ThreadData(const std::string& sanitized_thread_name)
next_retired_thread_data_(NULL),
sanitized_thread_name_(sanitized_thread_name),
incarnation_count_for_pool_(-1),
- current_stopwatch_(NULL) {
+ current_stopwatch_(NULL),
+ task_length_recording_enabled_for_uma_(false) {
DCHECK(sanitized_thread_name_.empty() ||
!isdigit(sanitized_thread_name_.back()));
PushToHeadOfList(); // Which sets real incarnation_count_for_pool_.
@@ -869,6 +870,10 @@ void ThreadData::OnProfilingPhaseCompletedOnThread(int profiling_phase) {
}
}
+void ThreadData::EnableTaskDurationRecordingForUMA() {
+ task_length_recording_enabled_for_uma_ = true;
+}
+
void ThreadData::EnsureTlsInitialization() {
if (base::subtle::Acquire_Load(&status_) >= DEACTIVATED)
return; // Someone else did the initialization.
@@ -937,11 +942,24 @@ base::TimeTicks ThreadData::Now() {
if (now_function_for_testing_)
return base::TimeTicks() +
base::TimeDelta::FromMilliseconds((*now_function_for_testing_)());
+
if (IsProfilerTimingEnabled() && TrackingStatus())
return base::TimeTicks::Now();
return base::TimeTicks(); // Super fast when disabled, or not compiled.
}
+// static
+base::TimeTicks ThreadData::Now(const ThreadData* thread_data) {
+ base::TimeTicks now = ThreadData::Now();
+ if (!now.is_null())
+ return now;
+ if (!thread_data)
+ return base::TimeTicks();
+ if (thread_data->task_length_recording_enabled_for_uma())
+ return base::TimeTicks::Now();
+ return base::TimeTicks();
+}
+
// static
void ThreadData::EnsureCleanupWasCalled(int major_threads_shutdown_count) {
base::AutoLock lock(*list_lock_.Pointer());
@@ -1069,14 +1087,13 @@ void TaskStopwatch::Start() {
DCHECK(state_ == CREATED);
state_ = RUNNING;
#endif
-
- start_time_ = ThreadData::Now();
+ current_thread_data_ = ThreadData::Get();
+ start_time_ = ThreadData::Now(current_thread_data_);
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
if (heap_tracking_enabled_)
heap_usage_.Start();
#endif
- current_thread_data_ = ThreadData::Get();
if (!current_thread_data_)
return;
@@ -1092,7 +1109,7 @@ void TaskStopwatch::Start() {
}
void TaskStopwatch::Stop() {
- const base::TimeTicks end_time = ThreadData::Now();
+ const base::TimeTicks end_time = ThreadData::Now(current_thread_data_);
#if DCHECK_IS_ON()
DCHECK(state_ == RUNNING);
state_ = STOPPED;
« base/tracked_objects.h ('K') | « base/tracked_objects.h ('k') | base/tracking_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698