Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CC_SCHEDULER_ROLLING_SAMPLE_WINDOW_H_ | |
| 6 #define CC_SCHEDULER_ROLLING_SAMPLE_WINDOW_H_ | |
| 7 | |
| 8 #include <list> | |
| 9 #include <set> | |
| 10 | |
| 11 #include "base/time.h" | |
| 12 #include "cc/base/cc_export.h" | |
| 13 | |
| 14 namespace cc { | |
| 15 | |
| 16 // Stores a limited number of samples. When the maximum size is reached, each | |
| 17 // insertion results in the deletion of the oldest remaining sample. | |
| 18 class CC_EXPORT RollingSampleWindow { | |
|
brianderson
2013/05/31 18:42:05
If we are going to use a generic class name like t
ajuma
2013/05/31 20:41:11
Renamed to RollingTimeDeltaHistory.
| |
| 19 public: | |
| 20 explicit RollingSampleWindow(size_t max_size); | |
| 21 | |
| 22 ~RollingSampleWindow(); | |
| 23 | |
| 24 void InsertSample(base::TimeDelta time); | |
| 25 | |
| 26 void Clear(); | |
| 27 | |
| 28 // Returns the smallest base::TimeDelta that is greater than or equal to | |
| 29 // the specified percent of samples. | |
| 30 base::TimeDelta Percentile(double percent) const; | |
| 31 | |
| 32 private: | |
| 33 typedef std::multiset<base::TimeDelta> TimeDeltaMultiset; | |
| 34 | |
| 35 TimeDeltaMultiset sample_set_; | |
| 36 std::list<TimeDeltaMultiset::iterator> chronological_sample_list_; | |
|
brianderson
2013/05/31 18:42:05
Would a std::deque be more efficient? Once it reac
ajuma
2013/05/31 20:41:11
Changed to a deque.
| |
| 37 size_t max_size_; | |
| 38 | |
| 39 DISALLOW_COPY_AND_ASSIGN(RollingSampleWindow); | |
| 40 }; | |
| 41 | |
| 42 } // namespace cc | |
| 43 | |
| 44 #endif // CC_SCHEDULER_ROLLING_SAMPLE_WINDOW_H_ | |
| OLD | NEW |