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

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

Issue 2265873004: [scheduler] Monitor renderer load level. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes according to comments Created 4 years, 4 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_TRAC KER_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_TRAC KER_H_
7
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/time/time.h"
11 #include "public/platform/WebCommon.h"
12
13 namespace blink {
14 namespace scheduler {
15
16 // This class tracks renderer load level, e.g. percentage of wall time spent
alex clarke (OOO till 29th) 2016/08/22 16:13:13 nit: i.e. the percentage...
altimin 2016/08/22 17:02:22 I meant that we also are going to track wakeups an
17 // running tasks.
18 // In order to avoid bias it reports load level at regular intervals.
19 class BLINK_PLATFORM_EXPORT ThreadLoadTracker {
20 public:
21 // Callback is called with (current_time, load_level) parameters.
22 using Callback = base::Callback<void(base::TimeTicks, double)>;
23
24 ThreadLoadTracker(base::TimeTicks now, const Callback& callback);
25 ~ThreadLoadTracker();
26
27 void Pause(base::TimeTicks now);
28 void Resume(base::TimeTicks now);
29
30 void RecordTaskTime(base::TimeTicks start_time, base::TimeTicks end_time);
31
32 void RecordIdle(base::TimeTicks now);
33
34 // TODO(altimin): Count wakeups.
35
36 private:
37 enum class ThreadState {
38 ACTIVE, PAUSED
39 };
40
41 enum class TaskState {
42 TASK_RUNNING, IDLE
43 };
44
45 void Advance(base::TimeTicks now, TaskState task_state);
alex clarke (OOO till 29th) 2016/08/22 16:13:13 Please add a comment explaining what this does. Y
altimin 2016/08/22 17:02:22 Comment added (also commented source in .cc file).
46
47 double Load();
48
49 base::TimeTicks current_time_;
alex clarke (OOO till 29th) 2016/08/22 16:13:13 Nit: This can't actually be the current time since
altimin 2016/08/22 17:02:22 Done.
50 base::TimeTicks next_reporting_time_;
51
52 ThreadState thread_state_;
53 base::TimeTicks last_state_change_time_;
54
55 base::TimeDelta total_time_;
56 base::TimeDelta total_runtime_;
57
58 // Start reporting values after |waiting_period_|.
59 base::TimeDelta waiting_period_;
60 base::TimeDelta reporting_interval_;
61
62 Callback callback_;
63
64 DISALLOW_COPY_AND_ASSIGN(ThreadLoadTracker);
65 };
66
67 } // namespace scheduler
68 } // namespace blink
69
70 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_T RACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698