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

Unified Diff: third_party/WebKit/Source/platform/scheduler/base/thread_load_tracker.h

Issue 2391593002: [scheduler] Change ThreadLoadTracker to use only recent data. (Closed)
Patch Set: Rebased 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/base/thread_load_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/scheduler/base/thread_load_tracker.h
diff --git a/third_party/WebKit/Source/platform/scheduler/base/thread_load_tracker.h b/third_party/WebKit/Source/platform/scheduler/base/thread_load_tracker.h
index 69299f34132cdcfb80d185c0ab3168dab08c895d..1d601fbbbce983cb7a6f21336741fd744db418e1 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/thread_load_tracker.h
+++ b/third_party/WebKit/Source/platform/scheduler/base/thread_load_tracker.h
@@ -16,12 +16,17 @@ namespace scheduler {
// This class tracks thread load level, i.e. percentage of wall time spent
// running tasks.
// In order to avoid bias it reports load level at regular intervals.
+// Every |reporting_interval_| time units, it reports the average thread load
+// level computed using a sliding window of width |reporting_interval_|.
class BLINK_PLATFORM_EXPORT ThreadLoadTracker {
public:
// Callback is called with (current_time, load_level) parameters.
using Callback = base::Callback<void(base::TimeTicks, double)>;
- ThreadLoadTracker(base::TimeTicks now, const Callback& callback);
+ ThreadLoadTracker(base::TimeTicks now,
+ const Callback& callback,
+ base::TimeDelta reporting_interval,
+ base::TimeDelta waiting_period);
~ThreadLoadTracker();
void Pause(base::TimeTicks now);
@@ -47,17 +52,21 @@ class BLINK_PLATFORM_EXPORT ThreadLoadTracker {
// |time_| is the last timestamp LoadTracker knows about.
base::TimeTicks time_;
base::TimeTicks next_reporting_time_;
+ // Total period for which this LoadTracker was active. Needed to discard
+ // first |waiting_period_| time.
+ base::TimeDelta total_active_time_;
ThreadState thread_state_;
base::TimeTicks last_state_change_time_;
- base::TimeDelta total_time_;
- base::TimeDelta total_runtime_;
-
// Start reporting values after |waiting_period_|.
base::TimeDelta waiting_period_;
base::TimeDelta reporting_interval_;
+ // Recorded run time in window
+ // [next_reporting_time - reporting_interval, next_reporting_time].
+ base::TimeDelta run_time_inside_window_;
+
Callback callback_;
DISALLOW_COPY_AND_ASSIGN(ThreadLoadTracker);
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/base/thread_load_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698