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

Side by Side Diff: net/quic/congestion_control/inter_arrival_bitrate_ramp_up_test.cc

Issue 125403006: Various QUIC cleanups to sync with internal code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include <algorithm> 5 #include <algorithm>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "net/quic/congestion_control/inter_arrival_bitrate_ramp_up.h" 9 #include "net/quic/congestion_control/inter_arrival_bitrate_ramp_up.h"
10 #include "net/quic/test_tools/mock_clock.h" 10 #include "net/quic/test_tools/mock_clock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 using std::min;
14
13 namespace net { 15 namespace net {
14 namespace test { 16 namespace test {
15 17
16 class InterArrivalBitrateRampUpTest : public ::testing::Test { 18 class InterArrivalBitrateRampUpTest : public ::testing::Test {
17 protected: 19 protected:
18 InterArrivalBitrateRampUpTest() 20 InterArrivalBitrateRampUpTest()
19 : one_ms_(QuicTime::Delta::FromMilliseconds(1)), 21 : one_ms_(QuicTime::Delta::FromMilliseconds(1)),
20 hundred_ms_(QuicTime::Delta::FromMilliseconds(100)), 22 hundred_ms_(QuicTime::Delta::FromMilliseconds(100)),
21 bitrate_ramp_up_(&clock_) { 23 bitrate_ramp_up_(&clock_) {
22 } 24 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 QuicBandwidth sent_bitrate = QuicBandwidth::Zero(); 111 QuicBandwidth sent_bitrate = QuicBandwidth::Zero();
110 bitrate_ramp_up_.Reset(start_rate, 112 bitrate_ramp_up_.Reset(start_rate,
111 available_channel_estimate, 113 available_channel_estimate,
112 channel_estimate); 114 channel_estimate);
113 115
114 // First concave growth, towards available_channel_estimate. 116 // First concave growth, towards available_channel_estimate.
115 // Should pass without being affected by the max_sent_rate. 117 // Should pass without being affected by the max_sent_rate.
116 for (int i = 0; i < 25; ++i) { 118 for (int i = 0; i < 25; ++i) {
117 clock_.AdvanceTime(hundred_ms_); 119 clock_.AdvanceTime(hundred_ms_);
118 // Cap our previus sent rate. 120 // Cap our previus sent rate.
119 sent_bitrate = std::min(sent_bitrate, max_sent_rate); 121 sent_bitrate = min(sent_bitrate, max_sent_rate);
120 sent_bitrate = bitrate_ramp_up_.GetNewBitrate(sent_bitrate); 122 sent_bitrate = bitrate_ramp_up_.GetNewBitrate(sent_bitrate);
121 EXPECT_GE(available_channel_estimate, sent_bitrate); 123 EXPECT_GE(available_channel_estimate, sent_bitrate);
122 EXPECT_LE(start_rate, sent_bitrate); 124 EXPECT_LE(start_rate, sent_bitrate);
123 } 125 }
124 clock_.AdvanceTime(hundred_ms_); 126 clock_.AdvanceTime(hundred_ms_);
125 // Cap our previus sent rate. 127 // Cap our previus sent rate.
126 sent_bitrate = std::min(sent_bitrate, max_sent_rate); 128 sent_bitrate = min(sent_bitrate, max_sent_rate);
127 sent_bitrate = bitrate_ramp_up_.GetNewBitrate(sent_bitrate); 129 sent_bitrate = bitrate_ramp_up_.GetNewBitrate(sent_bitrate);
128 EXPECT_LE(available_channel_estimate, sent_bitrate); 130 EXPECT_LE(available_channel_estimate, sent_bitrate);
129 131
130 // First convex growth, from available_channel_estimate. 132 // First convex growth, from available_channel_estimate.
131 for (int j = 0; j < 25; ++j) { 133 for (int j = 0; j < 25; ++j) {
132 clock_.AdvanceTime(hundred_ms_); 134 clock_.AdvanceTime(hundred_ms_);
133 // Cap our previus sent rate. 135 // Cap our previus sent rate.
134 sent_bitrate = std::min(sent_bitrate, max_sent_rate); 136 sent_bitrate = min(sent_bitrate, max_sent_rate);
135 sent_bitrate = bitrate_ramp_up_.GetNewBitrate(sent_bitrate); 137 sent_bitrate = bitrate_ramp_up_.GetNewBitrate(sent_bitrate);
136 EXPECT_LE(available_channel_estimate, sent_bitrate); 138 EXPECT_LE(available_channel_estimate, sent_bitrate);
137 EXPECT_GE(halfway_point, sent_bitrate); 139 EXPECT_GE(halfway_point, sent_bitrate);
138 } 140 }
139 clock_.AdvanceTime(hundred_ms_); 141 clock_.AdvanceTime(hundred_ms_);
140 sent_bitrate = std::min(sent_bitrate, max_sent_rate); 142 sent_bitrate = min(sent_bitrate, max_sent_rate);
141 sent_bitrate = bitrate_ramp_up_.GetNewBitrate(sent_bitrate); 143 sent_bitrate = bitrate_ramp_up_.GetNewBitrate(sent_bitrate);
142 // We expect 2 * sent_bitrate to cap the rate. 144 // We expect 2 * sent_bitrate to cap the rate.
143 EXPECT_LE(max_sent_rate.Add(max_sent_rate), sent_bitrate); 145 EXPECT_LE(max_sent_rate.Add(max_sent_rate), sent_bitrate);
144 // Remove our sent cap. 146 // Remove our sent cap.
145 // Expect bitrate to continue to ramp from its previous rate. 147 // Expect bitrate to continue to ramp from its previous rate.
146 for (int j = 0; j < 5; ++j) { 148 for (int j = 0; j < 5; ++j) {
147 clock_.AdvanceTime(hundred_ms_); 149 clock_.AdvanceTime(hundred_ms_);
148 sent_bitrate = bitrate_ramp_up_.GetNewBitrate(sent_bitrate); 150 sent_bitrate = bitrate_ramp_up_.GetNewBitrate(sent_bitrate);
149 EXPECT_LE(available_channel_estimate, sent_bitrate); 151 EXPECT_LE(available_channel_estimate, sent_bitrate);
150 EXPECT_LE(max_sent_rate.Add(max_sent_rate), sent_bitrate); 152 EXPECT_LE(max_sent_rate.Add(max_sent_rate), sent_bitrate);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 EXPECT_GE(channel_estimate, sent_bitrate); 399 EXPECT_GE(channel_estimate, sent_bitrate);
398 EXPECT_LE(halfway_point, sent_bitrate); 400 EXPECT_LE(halfway_point, sent_bitrate);
399 } 401 }
400 clock_.AdvanceTime(hundred_ms_); 402 clock_.AdvanceTime(hundred_ms_);
401 sent_bitrate = bitrate_ramp_up_.GetNewBitrate(sent_bitrate); 403 sent_bitrate = bitrate_ramp_up_.GetNewBitrate(sent_bitrate);
402 EXPECT_LE(channel_estimate, sent_bitrate); 404 EXPECT_LE(channel_estimate, sent_bitrate);
403 } 405 }
404 406
405 } // namespace test 407 } // namespace test
406 } // namespace net 408 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698