OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_FPS_METER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_FPS_METER_H_ |
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_FPS_METER_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_FPS_METER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 | 12 |
13 namespace vr_shell { | 13 namespace vr_shell { |
14 | 14 |
15 // Computes fps based on submitted frame times. | 15 // Computes fps based on submitted frame times. |
16 class FPSMeter { | 16 class FPSMeter { |
17 public: | 17 public: |
18 FPSMeter(); | 18 FPSMeter(); |
19 ~FPSMeter(); | 19 ~FPSMeter(); |
20 | 20 |
21 void AddFrame(const base::TimeTicks& time_stamp); | 21 void AddFrame(const base::TimeTicks& time_stamp); |
22 | 22 |
23 bool CanComputeFPS() const; | 23 bool CanComputeFPS() const; |
24 | 24 |
25 double GetFPS() const; | 25 double GetFPS() const; |
26 | 26 |
| 27 // Get sliding window size for tests. |
| 28 size_t GetNumFrameTimes(); |
| 29 |
27 private: | 30 private: |
28 size_t current_index_; | 31 size_t current_index_; |
29 int64_t total_time_us_; | 32 int64_t total_time_us_; |
30 base::TimeTicks last_time_stamp_; | 33 base::TimeTicks last_time_stamp_; |
31 std::vector<base::TimeDelta> frame_times_; | 34 std::vector<base::TimeDelta> frame_times_; |
32 DISALLOW_COPY_AND_ASSIGN(FPSMeter); | 35 DISALLOW_COPY_AND_ASSIGN(FPSMeter); |
33 }; | 36 }; |
34 | 37 |
35 } // namespace vr_shell | 38 } // namespace vr_shell |
36 | 39 |
37 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_FPS_METER_H_ | 40 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_FPS_METER_H_ |
OLD | NEW |