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

Side by Side Diff: chrome/browser/android/vr_shell/fps_meter.h

Issue 2892813002: Fix off-by-one in fps_meter, fix unit test to catch this. (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | chrome/browser/android/vr_shell/fps_meter.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 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_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/fps_meter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698