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 FRAME_COUNTER_H_
6 #define FRAME_COUNTER_H_
11 : frame_duration_accumulator_(0),
13 frames_per_second_(0) {}
16 // Record the current time, which is used to compute the frame duration
17 // when EndFrame() is called.
20 // Compute the delta since the last call to BeginFrame() and increment the
21 // frame count. Update the frame rate whenever the prescribed number of
22 // frames have been counted, or at least one second of simulator time has
23 // passed, whichever is less.
26 // Reset the frame counters back to 0.
29 // The current frame rate. Note that this is 0 for the first second in
30 // the accumulator, and is updated every 100 frames (and at least once
31 // every second of simulation time or so).
32 double frames_per_second() const {
33 return frames_per_second_
;
37 static const double kMicroSecondsPerSecond
= 1000000.0;
38 static const int32_t kFrameRateRefreshCount
= 100;
40 double frame_duration_accumulator_
; // Measured in microseconds.
43 double frames_per_second_
;
46 #endif // FRAME_COUNTER_H_