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

Unified Diff: components/scheduler/renderer/idle_time_estimator.h

Issue 1411133003: A better idle time estimator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2526
Patch Set: Created 5 years, 1 month 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 | « components/components_tests.gyp ('k') | components/scheduler/renderer/idle_time_estimator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/scheduler/renderer/idle_time_estimator.h
diff --git a/components/scheduler/renderer/idle_time_estimator.h b/components/scheduler/renderer/idle_time_estimator.h
new file mode 100644
index 0000000000000000000000000000000000000000..4b699154113cb53aafae696b3d48adae2b0bc9d9
--- /dev/null
+++ b/components/scheduler/renderer/idle_time_estimator.h
@@ -0,0 +1,58 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SCHEDULER_RENDERER_IDLE_TIME_ESTIMATOR_H_
+#define COMPONENTS_SCHEDULER_RENDERER_IDLE_TIME_ESTIMATOR_H_
+
+#include "base/message_loop/message_loop.h"
+#include "base/time/tick_clock.h"
+#include "cc/base/rolling_time_delta_history.h"
+#include "components/scheduler/base/task_queue.h"
+#include "components/scheduler/scheduler_export.h"
+
+namespace scheduler {
+
+// Estimates how much idle time there is available.
+class SCHEDULER_EXPORT IdleTimeEstimator
+ : public base::MessageLoop::TaskObserver {
+ public:
+ IdleTimeEstimator(const scoped_refptr<TaskQueue>& compositor_task_runner,
+ int sample_count,
+ double estimation_percentile);
+
+ ~IdleTimeEstimator() override;
+
+ // Expected Idle time is defined as: |compositor_frame_interval| minus
+ // expected compositor task duration.
+ base::TimeDelta GetExpectedIdleDuration(
+ base::TimeDelta compositor_frame_interval) const;
+
+ void DidCommitFrameToCompositor();
+
+ void Clear();
+
+ // TaskObserver implementation:
+ void WillProcessTask(const base::PendingTask& pending_task) override;
+ void DidProcessTask(const base::PendingTask& pending_task) override;
+
+ void SetTimeSourceForTesting(scoped_ptr<base::TickClock> time_source);
+
+ private:
+ scoped_refptr<TaskQueue> compositor_task_runner_;
+ cc::RollingTimeDeltaHistory per_frame_compositor_task_runtime_;
+ scoped_ptr<base::TickClock> time_source_;
+ double estimation_percentile_;
+
+ base::TimeTicks task_start_time_;
+ base::TimeTicks prev_commit_time_;
+ base::TimeDelta cumulative_compositor_runtime_;
+ int nesting_level_;
+ bool did_commit_;
+
+ DISALLOW_COPY_AND_ASSIGN(IdleTimeEstimator);
+};
+
+} // namespace scheduler
+
+#endif // COMPONENTS_SCHEDULER_RENDERER_IDLE_TIME_ESTIMATOR_H_
« no previous file with comments | « components/components_tests.gyp ('k') | components/scheduler/renderer/idle_time_estimator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698