net/nqe/observation_buffer_unittest.cc
// Verify that the percentiles are monotonically non-decreasing when a weight is
// applied.
Verify that the percentiles are monotonically non-decreasing when a weight is
applied.
Verify that the percentiles are monotonically non - decreasing when a weight is applied .
TEST(NetworkQualityObservationBufferTest, GetPercentileWithWeights) {
  std::map<std::string, std::string> variation_params;
  NetworkQualityEstimatorParams params(variation_params);
  base::SimpleTestTickClock tick_clock;
  tick_clock.Advance(base::TimeDelta::FromMinutes(1));
  ObservationBuffer observation_buffer(&params, &tick_clock, 0.98, 1.0);
  const base::TimeTicks now = tick_clock.NowTicks();
  for (int i = 1; i <= 100; ++i) {
    tick_clock.Advance(base::TimeDelta::FromSeconds(1));
    observation_buffer.AddObservation(
        Observation(i, tick_clock.NowTicks(), INT32_MIN,
                    NETWORK_QUALITY_OBSERVATION_SOURCE_TCP));
  }
  EXPECT_EQ(100U, observation_buffer.Size());
  int32_t result_lowest = INT32_MAX;
  int32_t result_highest = INT32_MIN;
  for (int i = 1; i <= 100; ++i) {
    size_t observations_count = 0;
    base::Optional<int32_t> result_i = observation_buffer.GetPercentile(
        now, INT32_MIN, i, &observations_count);
    EXPECT_EQ(100u, observations_count);
    ASSERT_TRUE(result_i.has_value());
    result_lowest = std::min(result_lowest, result_i.value());
    result_highest = std::max(result_highest, result_i.value());
    base::Optional<int32_t> result_i_1 = observation_buffer.GetPercentile(
        now, INT32_MIN, i - 1, &observations_count);
    EXPECT_EQ(100u, observations_count);
    ASSERT_TRUE(result_i_1.has_value());
    EXPECT_LE(result_i_1.value(), result_i.value());
  }
  EXPECT_LT(result_lowest, result_highest);
}
TEST ( NetworkQualityObservationBufferTest , GetPercentileWithWeights ) { std :: map < std :: string , std :: string > variation_params ; NetworkQualityEstimatorParams params ( variation_params ) ; base :: SimpleTestTickClock tick_clock ; tick_clock . Advance ( base :: TimeDelta :: FromMinutes ( 1 ) ) ; ObservationBuffer observation_buffer ( & params , & tick_clock , 0.98 , 1.0 ) ; const base :: TimeTicks now = tick_clock . NowTicks ( ) ; for ( int i = 1 ; i <= 100 ; ++ i ) { tick_clock . Advance ( base :: TimeDelta :: FromSeconds ( 1 ) ) ; observation_buffer . AddObservation ( Observation ( i , tick_clock . NowTicks ( ) , INT32_MIN , NETWORK_QUALITY_OBSERVATION_SOURCE_TCP ) ) ; } EXPECT_EQ ( 100U , observation_buffer . Size ( ) ) ; int32_t result_lowest = INT32_MAX ; int32_t result_highest = INT32_MIN ; for ( int i = 1 ; i <= 100 ; ++ i ) { size_t observations_count = 0 ; base :: Optional < int32_t > result_i = observation_buffer . GetPercentile ( now , INT32_MIN , i , & observations_count ) ; EXPECT_EQ ( 100u , observations_count ) ; ASSERT_TRUE ( result_i . has_value ( ) ) ; result_lowest = std :: min ( result_lowest , result_i . value ( ) ) ; result_highest = std :: max ( result_highest , result_i . value ( ) ) ; base :: Optional < int32_t > result_i_1 = observation_buffer . GetPercentile ( now , INT32_MIN , i - 1 , & observations_count ) ; EXPECT_EQ ( 100u , observations_count ) ; ASSERT_TRUE ( result_i_1 . has_value ( ) ) ; EXPECT_LE ( result_i_1 . value ( ) , result_i . value ( ) ) ; } EXPECT_LT ( result_lowest , result_highest ) ; }
Verify that the percentiles are monotonically non-decreasing when a weight is
applied.
Verify that the percentiles are monotonically non - decreasing when a weight is applied .
// Verify that i'th percentile is more than i-1'th percentile.