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

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

Issue 1835053002: Change default timestamp to 64 bits in all webrtc directories. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Add TODO for timestamp. Created 4 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 | « webrtc/base/physicalsocketserver.cc ('k') | webrtc/base/ratetracker.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 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_BASE_RATETRACKER_H_ 11 #ifndef WEBRTC_BASE_RATETRACKER_H_
12 #define WEBRTC_BASE_RATETRACKER_H_ 12 #define WEBRTC_BASE_RATETRACKER_H_
13 13
14 #include <stdlib.h> 14 #include <stdlib.h>
15 #include "webrtc/base/basictypes.h" 15 #include "webrtc/base/basictypes.h"
16 16
17 namespace rtc { 17 namespace rtc {
18 18
19 // Computes units per second over a given interval by tracking the units over 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 20 // each bucket of a given size and calculating the instantaneous rate assuming
21 // that over each bucket the rate was constant. 21 // that over each bucket the rate was constant.
22 class RateTracker { 22 class RateTracker {
23 public: 23 public:
24 RateTracker(uint32_t bucket_milliseconds, size_t bucket_count); 24 RateTracker(int64_t bucket_milliseconds, size_t bucket_count);
25 virtual ~RateTracker(); 25 virtual ~RateTracker();
26 26
27 // Computes the average rate over the most recent interval_milliseconds, 27 // Computes the average rate over the most recent interval_milliseconds,
28 // or if the first sample was added within this period, computes the rate 28 // or if the first sample was added within this period, computes the rate
29 // since the first sample was added. 29 // since the first sample was added.
30 double ComputeRateForInterval(uint32_t interval_milliseconds) const; 30 double ComputeRateForInterval(int64_t interval_milliseconds) const;
31 31
32 // Computes the average rate over the rate tracker's recording interval 32 // Computes the average rate over the rate tracker's recording interval
33 // of bucket_milliseconds * bucket_count. 33 // of bucket_milliseconds * bucket_count.
34 double ComputeRate() const { 34 double ComputeRate() const {
35 return ComputeRateForInterval(bucket_milliseconds_ * 35 return ComputeRateForInterval(bucket_milliseconds_ *
36 static_cast<uint32_t>(bucket_count_)); 36 static_cast<int64_t>(bucket_count_));
37 } 37 }
38 38
39 // Computes the average rate since the first sample was added to the 39 // Computes the average rate since the first sample was added to the
40 // rate tracker. 40 // rate tracker.
41 double ComputeTotalRate() const; 41 double ComputeTotalRate() const;
42 42
43 // The total number of samples added. 43 // The total number of samples added.
44 size_t TotalSampleCount() const; 44 size_t TotalSampleCount() const;
45 45
46 // Reads the current time in order to determine the appropriate bucket for 46 // Reads the current time in order to determine the appropriate bucket for
47 // these samples, and increments the count for that bucket by sample_count. 47 // these samples, and increments the count for that bucket by sample_count.
48 void AddSamples(size_t sample_count); 48 void AddSamples(size_t sample_count);
49 49
50 protected: 50 protected:
51 // overrideable for tests 51 // overrideable for tests
52 virtual uint32_t Time() const; 52 virtual int64_t Time() const;
53 53
54 private: 54 private:
55 void EnsureInitialized(); 55 void EnsureInitialized();
56 size_t NextBucketIndex(size_t bucket_index) const; 56 size_t NextBucketIndex(size_t bucket_index) const;
57 57
58 const uint32_t bucket_milliseconds_; 58 const int64_t bucket_milliseconds_;
59 const size_t bucket_count_; 59 const size_t bucket_count_;
60 size_t* sample_buckets_; 60 size_t* sample_buckets_;
61 size_t total_sample_count_; 61 size_t total_sample_count_;
62 size_t current_bucket_; 62 size_t current_bucket_;
63 uint32_t bucket_start_time_milliseconds_; 63 int64_t bucket_start_time_milliseconds_;
64 uint32_t initialization_time_milliseconds_; 64 int64_t initialization_time_milliseconds_;
65 }; 65 };
66 66
67 } // namespace rtc 67 } // namespace rtc
68 68
69 #endif // WEBRTC_BASE_RATETRACKER_H_ 69 #endif // WEBRTC_BASE_RATETRACKER_H_
OLDNEW
« no previous file with comments | « webrtc/base/physicalsocketserver.cc ('k') | webrtc/base/ratetracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698