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

Side by Side Diff: cc/debug/lap_timer.cc

Issue 1082103003: Make a couple of SurfaceAggregatorPerfTests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « cc/debug/lap_timer.h ('k') | cc/surfaces/surface_aggregator_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/debug/lap_timer.h" 5 #include "cc/debug/lap_timer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace cc { 9 namespace cc {
10 10
11 namespace { 11 namespace {
12 12
13 base::TimeTicks Now() { 13 base::TimeTicks Now() {
14 return base::TimeTicks::IsThreadNowSupported() ? base::TimeTicks::ThreadNow() 14 return base::TimeTicks::IsThreadNowSupported() ? base::TimeTicks::ThreadNow()
15 : base::TimeTicks::Now(); 15 : base::TimeTicks::Now();
16 } 16 }
17 17
18 // Default values.
19 static const int kTimeLimitMillis = 3000;
20 static const int kWarmupRuns = 5;
21 static const int kTimeCheckInterval = 10;
22
18 } // namespace 23 } // namespace
19 24
20 LapTimer::LapTimer(int warmup_laps, 25 LapTimer::LapTimer(int warmup_laps,
21 base::TimeDelta time_limit, 26 base::TimeDelta time_limit,
22 int check_interval) 27 int check_interval)
23 : warmup_laps_(warmup_laps), 28 : warmup_laps_(warmup_laps),
24 remaining_warmups_(0), 29 remaining_warmups_(0),
25 remaining_no_check_laps_(0), 30 remaining_no_check_laps_(0),
26 time_limit_(time_limit), 31 time_limit_(time_limit),
27 check_interval_(check_interval) { 32 check_interval_(check_interval) {
28 DCHECK_GT(check_interval, 0); 33 DCHECK_GT(check_interval, 0);
29 Reset(); 34 Reset();
30 } 35 }
31 36
37 LapTimer::LapTimer()
38 : LapTimer(kWarmupRuns,
39 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
40 kTimeCheckInterval) {
41 }
42
32 void LapTimer::Reset() { 43 void LapTimer::Reset() {
33 accumulator_ = base::TimeDelta(); 44 accumulator_ = base::TimeDelta();
34 num_laps_ = 0; 45 num_laps_ = 0;
35 remaining_warmups_ = warmup_laps_; 46 remaining_warmups_ = warmup_laps_;
36 remaining_no_check_laps_ = check_interval_; 47 remaining_no_check_laps_ = check_interval_;
37 Start(); 48 Start();
38 } 49 }
39 50
40 void LapTimer::Start() { 51 void LapTimer::Start() {
41 start_time_ = Now(); 52 start_time_ = Now();
(...skipping 29 matching lines...) Expand all
71 } 82 }
72 83
73 float LapTimer::LapsPerSecond() { 84 float LapTimer::LapsPerSecond() {
74 DCHECK(HasTimedAllLaps()); 85 DCHECK(HasTimedAllLaps());
75 return num_laps_ / accumulator_.InSecondsF(); 86 return num_laps_ / accumulator_.InSecondsF();
76 } 87 }
77 88
78 int LapTimer::NumLaps() { return num_laps_; } 89 int LapTimer::NumLaps() { return num_laps_; }
79 90
80 } // namespace cc 91 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/lap_timer.h ('k') | cc/surfaces/surface_aggregator_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698