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

Side by Side Diff: webrtc/base/bucketratetracker.h

Issue 1279433006: Add a rate tracker that tracks rate over a given interval split up into buckets that accumulate uni… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix type issues on win64. Created 5 years, 4 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_BASE_BUCKETRATETRACKER_H_
12 #define WEBRTC_BASE_BUCKETRATETRACKER_H_
13
14 #include <stdlib.h>
15 #include "webrtc/base/basictypes.h"
16
17 namespace rtc {
18
19 // Computes units per second over a given interval by tracking the units over
20 // each bucket of a given size and calculating the instantaneous rate assuming
21 // that over each bucket the rate was constant.
22 class BucketRateTracker {
23 public:
24 BucketRateTracker(uint32 bucket_milliseconds, uint32 interval_buckets);
noahric 2015/08/07 23:56:38 maybe size_t bucket_count? (and bucket_count_)
tpsiaki 2015/08/11 18:33:27 Done.
25 virtual ~BucketRateTracker();
26
27 size_t units_second() const;
noahric 2015/08/07 23:56:38 double? Also since this is simply returning a fiel
tpsiaki 2015/08/11 18:33:27 Done.
28 void Update(size_t units);
noahric 2015/08/07 23:56:38 I know this matches RateTracker, but I feel like A
tpsiaki 2015/08/11 18:33:27 Done.
29
30 protected:
31 // overrideable for tests
32 virtual uint32 Time() const;
33
34 private:
35 void EnsureInitialized();
36
37 const uint32 bucket_milliseconds_;
38 const uint32 interval_buckets_;
39 size_t* unit_buckets_;
40 uint32 current_bucket_;
41 uint32 bucket_start_time_;
42 uint32 initialization_time_;
43 };
44
45 // Computes units per second over a given interval by dividing it into buckets
46 // of one second each and calculating the rate over the appropriate number of
47 // buckets.
48 class IntervalRateTracker : public BucketRateTracker {
49 public:
50 explicit IntervalRateTracker(uint32 interval_seconds)
51 : BucketRateTracker(1000u, interval_seconds) {}
52 };
53
54 } // namespace rtc
55
56 #endif // WEBRTC_BASE_BUCKETRATETRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698