cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / cc / test / lap_timer.h
blob1ab05f5ab60efd28821ef43fc20f435852fa06f4
1 // Copyright 2013 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.
5 #ifndef CC_TEST_LAP_TIMER_H_
6 #define CC_TEST_LAP_TIMER_H_
8 #include "base/time/time.h"
10 namespace cc {
12 // LapTimer is used to calculate average times per "Lap" in perf tests.
13 // Current() reports the time since the last call to Start().
14 // Store() adds the time since the last call to Start() to the accumulator, and
15 // resets the start time to now. Stored() returns the accumulated time.
16 // NextLap increments the lap counter, used in counting the per lap averages.
17 // If you initialize the LapTimer with a non zero warmup_laps, it will ignore
18 // the times for that many laps at the start.
19 // If you set the time_limit then you can use HasTimeLimitExpired() to see if
20 // the current accumulated time has crossed that threshold, with an optimization
21 // that it only tests this every check_interval laps.
22 class LapTimer {
23 public:
24 LapTimer(int warmup_laps, base::TimeDelta time_limit, int check_interval);
25 // Resets the timer back to it's starting state.
26 void Reset();
27 // Sets the start point to now.
28 void Start();
29 // Returns true if there are no more warmup laps to do.
30 bool IsWarmedUp();
31 // Advance the lap counter and update the accumulated time.
32 // The accumulated time is only updated every check_interval laps.
33 // If accumulating then the start point will also be updated.
34 void NextLap();
35 // Returns true if the stored time has exceeded the time limit specified.
36 // May cause a call to Store().
37 bool HasTimeLimitExpired();
38 // The average milliseconds per lap.
39 float MsPerLap();
40 // The number of laps per second.
41 float LapsPerSecond();
42 // The number of laps recorded.
43 int NumLaps();
45 private:
46 base::TimeTicks start_time_;
47 base::TimeDelta accumulator_;
48 int num_laps_;
49 int warmup_laps_;
50 int remaining_warmups_;
51 base::TimeDelta time_limit_;
52 int check_interval_;
53 bool accumulated_;
55 DISALLOW_COPY_AND_ASSIGN(LapTimer);
58 } // namespace cc
60 #endif // CC_TEST_LAP_TIMER_H_