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

Side by Side Diff: components/scheduler/renderer/task_cost_estimator.cc

Issue 1303353003: scheduler: Disable expensive timers during main thread user input (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments. Created 5 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 2015 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 #include "components/scheduler/renderer/task_cost_estimator.h"
6
7 namespace scheduler {
8
9 TaskCostEstimator::TaskCostEstimator(int sample_count,
10 double estimation_percentile)
11 : rolling_time_delta_history_(sample_count),
12 outstanding_task_count_(0),
13 estimation_percentile_(estimation_percentile) {}
14
15 TaskCostEstimator::~TaskCostEstimator() {}
16
17 void TaskCostEstimator::WillProcessTask(const base::PendingTask& pending_task) {
18 // Avoid measuring the duration in nested run loops.
19 if (++outstanding_task_count_ == 1)
20 task_start_time_ = Now();
21 }
22
23 void TaskCostEstimator::DidProcessTask(const base::PendingTask& pending_task) {
24 if (--outstanding_task_count_ == 0) {
25 base::TimeDelta duration = Now() - task_start_time_;
26 rolling_time_delta_history_.InsertSample(duration);
27
28 // TODO(skyostil): Should we do this less often?
29 expected_task_duration_ =
30 rolling_time_delta_history_.Percentile(estimation_percentile_);
31 }
32 }
33
34 base::TimeTicks TaskCostEstimator::Now() {
35 return base::TimeTicks::Now();
36 }
37
38 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/renderer/task_cost_estimator.h ('k') | components/scheduler/renderer/task_cost_estimator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698