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

Unified Diff: net/quic/congestion_control/cubic_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/congestion_control/cubic.cc ('k') | net/quic/congestion_control/fix_rate_sender.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/congestion_control/cubic_test.cc
diff --git a/net/quic/congestion_control/cubic_test.cc b/net/quic/congestion_control/cubic_test.cc
index c01bb0506438416cbfd59f67911c37c568477b63..8e0d8e9e777d77b376bbf49e9cd7295adbb46393 100644
--- a/net/quic/congestion_control/cubic_test.cc
+++ b/net/quic/congestion_control/cubic_test.cc
@@ -4,7 +4,6 @@
#include "base/basictypes.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "net/quic/congestion_control/cubic.h"
#include "net/quic/test_tools/mock_clock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -12,57 +11,19 @@
namespace net {
namespace test {
-class CubicPeer : public Cubic {
- public:
- explicit CubicPeer(QuicClock* clock)
- : Cubic(clock) {
- }
- using Cubic::CubeRoot;
-};
-
class CubicTest : public ::testing::Test {
protected:
CubicTest()
: one_ms_(QuicTime::Delta::FromMilliseconds(1)),
- hundred_ms_(QuicTime::Delta::FromMilliseconds(100)) {
- }
- virtual void SetUp() {
- cubic_.reset(new CubicPeer(&clock_));
+ hundred_ms_(QuicTime::Delta::FromMilliseconds(100)),
+ cubic_(&clock_) {
}
const QuicTime::Delta one_ms_;
const QuicTime::Delta hundred_ms_;
MockClock clock_;
- scoped_ptr<CubicPeer> cubic_;
+ Cubic cubic_;
};
-TEST_F(CubicTest, CubeRootLow) {
- for (uint32 i = 1; i < 256; ++i) {
- uint64 cube = i * i * i;
- uint8 cube_root = cubic_->CubeRoot(cube);
- EXPECT_EQ(i, cube_root);
- }
-}
-
-TEST_F(CubicTest, CubeRootHigh) {
- // Test the range we will opperate in, 1300 to 130 000.
- // We expect some loss in accuracy, accepting +-0.2%.
- for (uint64 i = 1300; i < 20000; i += 100) {
- uint64 cube = i * i * i;
- uint32 cube_root = cubic_->CubeRoot(cube);
- uint32 margin = cube_root >> 9; // Calculate 0.2% roughly by
- // dividing by 512.
- EXPECT_LE(i - margin, cube_root);
- EXPECT_GE(i + margin, cube_root);
- }
- for (uint64 i = 20000; i < 130000; i *= 2) {
- uint64 cube = i * i * i;
- uint32 cube_root = cubic_->CubeRoot(cube);
- uint32 margin = cube_root >> 9;
- EXPECT_LE(i - margin, cube_root);
- EXPECT_GE(i + margin, cube_root);
- }
-}
-
TEST_F(CubicTest, AboveOrgin) {
// Convex growth.
const QuicTime::Delta rtt_min = hundred_ms_;
@@ -71,17 +32,17 @@ TEST_F(CubicTest, AboveOrgin) {
// Initialize the state.
clock_.AdvanceTime(one_ms_);
EXPECT_EQ(expected_cwnd,
- cubic_->CongestionWindowAfterAck(current_cwnd, rtt_min));
+ cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min));
current_cwnd = expected_cwnd;
// Normal TCP phase.
for (int i = 0; i < 48; ++i) {
for (uint32 n = 1; n < current_cwnd; ++n) {
// Call once per ACK.
EXPECT_EQ(current_cwnd,
- cubic_->CongestionWindowAfterAck(current_cwnd, rtt_min));
+ cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min));
}
clock_.AdvanceTime(hundred_ms_);
- current_cwnd = cubic_->CongestionWindowAfterAck(current_cwnd, rtt_min);
+ current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
EXPECT_EQ(expected_cwnd, current_cwnd);
expected_cwnd++;
}
@@ -90,10 +51,10 @@ TEST_F(CubicTest, AboveOrgin) {
for (uint32 n = 1; n < current_cwnd; ++n) {
// Call once per ACK.
EXPECT_EQ(current_cwnd,
- cubic_->CongestionWindowAfterAck(current_cwnd, rtt_min));
+ cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min));
}
clock_.AdvanceTime(hundred_ms_);
- current_cwnd = cubic_->CongestionWindowAfterAck(current_cwnd, rtt_min);
+ current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
}
float elapsed_time_s = 10.0f + 0.1f; // We need to add the RTT here.
expected_cwnd = 11 + (elapsed_time_s * elapsed_time_s * elapsed_time_s * 410)
@@ -108,13 +69,13 @@ TEST_F(CubicTest, LossEvents) {
// Initialize the state.
clock_.AdvanceTime(one_ms_);
EXPECT_EQ(expected_cwnd,
- cubic_->CongestionWindowAfterAck(current_cwnd, rtt_min));
+ cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min));
expected_cwnd = current_cwnd * 939 / 1024;
EXPECT_EQ(expected_cwnd,
- cubic_->CongestionWindowAfterPacketLoss(current_cwnd));
+ cubic_.CongestionWindowAfterPacketLoss(current_cwnd));
expected_cwnd = current_cwnd * 939 / 1024;
EXPECT_EQ(expected_cwnd,
- cubic_->CongestionWindowAfterPacketLoss(current_cwnd));
+ cubic_.CongestionWindowAfterPacketLoss(current_cwnd));
}
TEST_F(CubicTest, BelowOrgin) {
@@ -125,26 +86,26 @@ TEST_F(CubicTest, BelowOrgin) {
// Initialize the state.
clock_.AdvanceTime(one_ms_);
EXPECT_EQ(expected_cwnd,
- cubic_->CongestionWindowAfterAck(current_cwnd, rtt_min));
+ cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min));
expected_cwnd = current_cwnd * 939 / 1024;
EXPECT_EQ(expected_cwnd,
- cubic_->CongestionWindowAfterPacketLoss(current_cwnd));
+ cubic_.CongestionWindowAfterPacketLoss(current_cwnd));
current_cwnd = expected_cwnd;
// First update after epoch.
- current_cwnd = cubic_->CongestionWindowAfterAck(current_cwnd, rtt_min);
+ current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
// Cubic phase.
for (int i = 0; i < 54; ++i) {
for (uint32 n = 1; n < current_cwnd; ++n) {
// Call once per ACK.
EXPECT_EQ(current_cwnd,
- cubic_->CongestionWindowAfterAck(current_cwnd, rtt_min));
+ cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min));
}
clock_.AdvanceTime(hundred_ms_);
- current_cwnd = cubic_->CongestionWindowAfterAck(current_cwnd, rtt_min);
+ current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
}
expected_cwnd = 440;
EXPECT_EQ(expected_cwnd, current_cwnd);
}
-} // namespace testing
+} // namespace test
} // namespace net
« no previous file with comments | « net/quic/congestion_control/cubic.cc ('k') | net/quic/congestion_control/fix_rate_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698