| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/quic/congestion_control/rtt_stats.h" | 5 #include "net/quic/congestion_control/rtt_stats.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // A new all time low sets both the min_rtt and the recent_min_rtt. | 147 // A new all time low sets both the min_rtt and the recent_min_rtt. |
| 148 rtt_sample = QuicTime::Delta::FromMilliseconds(5); | 148 rtt_sample = QuicTime::Delta::FromMilliseconds(5); |
| 149 rtt_stats_.UpdateRtt(rtt_sample, QuicTime::Delta::Zero(), now); | 149 rtt_stats_.UpdateRtt(rtt_sample, QuicTime::Delta::Zero(), now); |
| 150 | 150 |
| 151 EXPECT_EQ(rtt_sample, rtt_stats_.min_rtt()); | 151 EXPECT_EQ(rtt_sample, rtt_stats_.min_rtt()); |
| 152 EXPECT_EQ(rtt_sample, RttStatsPeer::GetQuarterWindowRtt(&rtt_stats_)); | 152 EXPECT_EQ(rtt_sample, RttStatsPeer::GetQuarterWindowRtt(&rtt_stats_)); |
| 153 EXPECT_EQ(rtt_sample, RttStatsPeer::GetHalfWindowRtt(&rtt_stats_)); | 153 EXPECT_EQ(rtt_sample, RttStatsPeer::GetHalfWindowRtt(&rtt_stats_)); |
| 154 EXPECT_EQ(rtt_sample, rtt_stats_.recent_min_rtt()); | 154 EXPECT_EQ(rtt_sample, rtt_stats_.recent_min_rtt()); |
| 155 } | 155 } |
| 156 | 156 |
| 157 TEST_F(RttStatsTest, ExpireSmoothedMetrics) { |
| 158 QuicTime::Delta initial_rtt = QuicTime::Delta::FromMilliseconds(10); |
| 159 rtt_stats_.UpdateRtt(initial_rtt, QuicTime::Delta::Zero(), QuicTime::Zero()); |
| 160 EXPECT_EQ(initial_rtt, rtt_stats_.min_rtt()); |
| 161 EXPECT_EQ(initial_rtt, rtt_stats_.recent_min_rtt()); |
| 162 EXPECT_EQ(initial_rtt, rtt_stats_.SmoothedRtt()); |
| 157 | 163 |
| 164 EXPECT_EQ(initial_rtt.Multiply(0.5), rtt_stats_.mean_deviation()); |
| 165 |
| 166 // Update once with a 20ms RTT. |
| 167 QuicTime::Delta doubled_rtt = initial_rtt.Multiply(2); |
| 168 rtt_stats_.UpdateRtt(doubled_rtt, QuicTime::Delta::Zero(), QuicTime::Zero()); |
| 169 EXPECT_EQ(initial_rtt.Multiply(1.125), rtt_stats_.SmoothedRtt()); |
| 170 |
| 171 // Expire the smoothed metrics, increasing smoothed rtt and mean deviation. |
| 172 rtt_stats_.ExpireSmoothedMetrics(); |
| 173 EXPECT_EQ(doubled_rtt, rtt_stats_.SmoothedRtt()); |
| 174 EXPECT_EQ(initial_rtt.Multiply(0.875), rtt_stats_.mean_deviation()); |
| 175 } |
| 158 | 176 |
| 159 } // namespace test | 177 } // namespace test |
| 160 } // namespace net | 178 } // namespace net |
| OLD | NEW |