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

Unified Diff: chrome/browser/android/vr_shell/fps_meter.h

Issue 2901213002: Add SlidingAverage to FPSMeter, use for WebVR prediction time (Closed)
Patch Set: Fix "Complex destructor has an inline body" for = default. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/fps_meter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/fps_meter.h
diff --git a/chrome/browser/android/vr_shell/fps_meter.h b/chrome/browser/android/vr_shell/fps_meter.h
index c52f4100ee599367977f2f1066de461f181be81c..86da9763d185375248271f2d3281c8d2a186c5f8 100644
--- a/chrome/browser/android/vr_shell/fps_meter.h
+++ b/chrome/browser/android/vr_shell/fps_meter.h
@@ -12,10 +12,32 @@
namespace vr_shell {
+class SampleQueue {
+ public:
+ explicit SampleQueue(size_t window_size);
+ ~SampleQueue();
+
+ int64_t GetSum() const { return sum_; }
+
+ void AddSample(int64_t value);
+
+ size_t GetCount() const { return samples_.size(); }
+
+ // Get sliding window size for tests.
+ size_t GetWindowSize() const { return window_size_; }
+
+ private:
+ int64_t sum_ = 0;
+ size_t current_index_ = 0;
+ size_t window_size_;
+ std::vector<int64_t> samples_;
+};
+
// Computes fps based on submitted frame times.
class FPSMeter {
public:
FPSMeter();
+ explicit FPSMeter(size_t window_size);
~FPSMeter();
void AddFrame(const base::TimeTicks& time_stamp);
@@ -28,13 +50,24 @@ class FPSMeter {
size_t GetNumFrameTimes();
private:
- size_t current_index_;
- int64_t total_time_us_;
+ SampleQueue frame_times_;
base::TimeTicks last_time_stamp_;
- std::vector<base::TimeDelta> frame_times_;
DISALLOW_COPY_AND_ASSIGN(FPSMeter);
};
+class SlidingAverage {
+ public:
+ explicit SlidingAverage(size_t window_size);
+ ~SlidingAverage();
+
+ void AddSample(int64_t value);
+ int64_t GetAverageOrDefault(int64_t default_value) const;
+ int64_t GetAverage() const { return GetAverageOrDefault(0); }
+
+ private:
+ SampleQueue values_;
+};
+
} // namespace vr_shell
#endif // CHROME_BROWSER_ANDROID_VR_SHELL_FPS_METER_H_
« 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