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

Unified Diff: net/nqe/network_quality_estimator_unittest.cc

Issue 2710973003: Record RTT prediction accuracy when using average algorithms (Closed)
Patch Set: Created 3 years, 10 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
Index: net/nqe/network_quality_estimator_unittest.cc
diff --git a/net/nqe/network_quality_estimator_unittest.cc b/net/nqe/network_quality_estimator_unittest.cc
index 55e3825be0c8aa50dc5f25cc092e8feda59f629c..0e69735809736cdbb58ce487fa452f0e76051fae 100644
--- a/net/nqe/network_quality_estimator_unittest.cc
+++ b/net/nqe/network_quality_estimator_unittest.cc
@@ -18,6 +18,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_samples.h"
+#include "base/optional.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/histogram_tester.h"
@@ -300,6 +301,7 @@ TEST(NetworkQualityEstimatorTest, TestKbpsRTTUpdates) {
// Verify that metrics are logged correctly on main-frame requests.
histogram_tester.ExpectTotalCount("NQE.MainFrame.RTT.Percentile50", 1);
+ histogram_tester.ExpectTotalCount("NQE.WeightedAverage.MainFrame.RTT", 1);
histogram_tester.ExpectTotalCount("NQE.MainFrame.RTT.Percentile50.Unknown",
1);
histogram_tester.ExpectTotalCount("NQE.MainFrame.TransportRTT.Percentile50",
@@ -546,8 +548,7 @@ TEST(NetworkQualityEstimatorTest, StoreObservations) {
context.set_network_quality_estimator(&estimator);
context.Init();
- // Push more observations than the maximum buffer size.
- const size_t kMaxObservations = 1000;
+ const size_t kMaxObservations = 10;
for (size_t i = 0; i < kMaxObservations; ++i) {
std::unique_ptr<URLRequest> request(context.CreateRequest(
estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
@@ -579,8 +580,9 @@ TEST(NetworkQualityEstimatorTest, ComputedPercentiles) {
NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC);
EXPECT_EQ(nqe::internal::InvalidRTT(),
- estimator.GetRTTEstimateInternal(disallowed_observation_sources,
- base::TimeTicks(), 100));
+ estimator.GetRTTEstimateInternal(
+ disallowed_observation_sources, base::TimeTicks(),
+ base::Optional<NetworkQualityEstimator::Statistic>(), 100));
EXPECT_EQ(nqe::internal::kInvalidThroughput,
estimator.GetDownlinkThroughputKbpsEstimateInternal(
base::TimeTicks(), 100));
@@ -590,8 +592,7 @@ TEST(NetworkQualityEstimatorTest, ComputedPercentiles) {
context.set_network_quality_estimator(&estimator);
context.Init();
- // Number of observations are more than the maximum buffer size.
- for (size_t i = 0; i < 1000U; ++i) {
+ for (size_t i = 0; i < 10U; ++i) {
std::unique_ptr<URLRequest> request(context.CreateRequest(
estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
request->Start();
@@ -603,8 +604,9 @@ TEST(NetworkQualityEstimatorTest, ComputedPercentiles) {
EXPECT_GT(estimator.GetDownlinkThroughputKbpsEstimateInternal(
base::TimeTicks(), i),
0);
- EXPECT_LT(estimator.GetRTTEstimateInternal(disallowed_observation_sources,
- base::TimeTicks(), i),
+ EXPECT_LT(estimator.GetRTTEstimateInternal(
+ disallowed_observation_sources, base::TimeTicks(),
+ base::Optional<NetworkQualityEstimator::Statistic>(), i),
base::TimeDelta::Max());
if (i != 0) {
@@ -614,11 +616,30 @@ TEST(NetworkQualityEstimatorTest, ComputedPercentiles) {
estimator.GetDownlinkThroughputKbpsEstimateInternal(
base::TimeTicks(), i - 1));
+ // Weighted average statistic should be computed correctly.
+ EXPECT_NE(nqe::internal::InvalidRTT(),
+ estimator.GetRTTEstimateInternal(
+ disallowed_observation_sources, base::TimeTicks(),
+ NetworkQualityEstimator::STATISTIC_WEIGHTED_AVERAGE, i));
+
+ // Weighted average statistic should disregard the value of the percentile
+ // argument.
+ EXPECT_EQ(
+ estimator.GetRTTEstimateInternal(
+ disallowed_observation_sources, base::TimeTicks(),
+ NetworkQualityEstimator::STATISTIC_WEIGHTED_AVERAGE, i),
+ estimator.GetRTTEstimateInternal(
+ disallowed_observation_sources, base::TimeTicks(),
+ NetworkQualityEstimator::STATISTIC_WEIGHTED_AVERAGE, i - 1));
+
// RTT percentiles are in increasing order.
- EXPECT_GE(estimator.GetRTTEstimateInternal(disallowed_observation_sources,
- base::TimeTicks(), i),
- estimator.GetRTTEstimateInternal(disallowed_observation_sources,
- base::TimeTicks(), i - 1));
+ EXPECT_GE(
+ estimator.GetRTTEstimateInternal(
+ disallowed_observation_sources, base::TimeTicks(),
+ base::Optional<NetworkQualityEstimator::Statistic>(), i),
+ estimator.GetRTTEstimateInternal(
+ disallowed_observation_sources, base::TimeTicks(),
+ base::Optional<NetworkQualityEstimator::Statistic>(), i - 1));
}
}
}
@@ -2299,6 +2320,7 @@ TEST(NetworkQualityEstimatorTest, MAYBE_RecordAccuracy) {
// Network was predicted to be slow and actually was slow.
estimator.set_start_time_null_http_rtt(test.rtt);
estimator.set_recent_http_rtt(test.recent_rtt);
+ estimator.set_rtt_estimate_internal(test.recent_rtt);
estimator.set_start_time_null_transport_rtt(test.rtt);
estimator.set_recent_transport_rtt(test.recent_rtt);
estimator.set_start_time_null_downlink_throughput_kbps(
@@ -2394,6 +2416,15 @@ TEST(NetworkQualityEstimatorTest, MAYBE_RecordAccuracy) {
rtt_sign_suffix_with_zero_samples + "." + interval_value +
".300_620",
0);
+
+ // All samples are recorded in bucket 0 because recent HTTP RTT and
+ // HTTP RTT are equal when weighted average algorithm is used.
+ histogram_tester.ExpectUniqueSample(
+ "NQE.WeightedAverage.Accuracy.HttpRTT.EstimatedObservedDiff."
+ "Positive." +
+ interval_value + ".300_620",
+ 0, 1);
+
histogram_tester.ExpectUniqueSample(
"NQE.Accuracy.TransportRTT.EstimatedObservedDiff." +
rtt_sign_suffix_with_one_sample + "." + interval_value +

Powered by Google App Engine
This is Rietveld 408576698