|
|
|
@ -51,8 +51,7 @@ TEST(BdpEstimatorTest, NoOp) { BdpEstimator est("test"); } |
|
|
|
|
|
|
|
|
|
TEST(BdpEstimatorTest, EstimateBdpNoSamples) { |
|
|
|
|
BdpEstimator est("test"); |
|
|
|
|
int64_t estimate; |
|
|
|
|
est.EstimateBdp(&estimate); |
|
|
|
|
est.EstimateBdp(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
@ -80,16 +79,14 @@ void AddSample(BdpEstimator *estimator, int64_t sample) { |
|
|
|
|
TEST(BdpEstimatorTest, GetEstimate1Sample) { |
|
|
|
|
BdpEstimator est("test"); |
|
|
|
|
AddSample(&est, 100); |
|
|
|
|
int64_t estimate; |
|
|
|
|
est.EstimateBdp(&estimate); |
|
|
|
|
est.EstimateBdp(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(BdpEstimatorTest, GetEstimate2Samples) { |
|
|
|
|
BdpEstimator est("test"); |
|
|
|
|
AddSample(&est, 100); |
|
|
|
|
AddSample(&est, 100); |
|
|
|
|
int64_t estimate; |
|
|
|
|
est.EstimateBdp(&estimate); |
|
|
|
|
est.EstimateBdp(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(BdpEstimatorTest, GetEstimate3Samples) { |
|
|
|
@ -97,17 +94,10 @@ TEST(BdpEstimatorTest, GetEstimate3Samples) { |
|
|
|
|
AddSample(&est, 100); |
|
|
|
|
AddSample(&est, 100); |
|
|
|
|
AddSample(&est, 100); |
|
|
|
|
int64_t estimate; |
|
|
|
|
est.EstimateBdp(&estimate); |
|
|
|
|
est.EstimateBdp(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
|
static int64_t GetEstimate(const BdpEstimator &estimator) { |
|
|
|
|
int64_t out; |
|
|
|
|
EXPECT_TRUE(estimator.EstimateBdp(&out)); |
|
|
|
|
return out; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int64_t NextPow2(int64_t v) { |
|
|
|
|
v--; |
|
|
|
|
v |= v >> 1; |
|
|
|
@ -134,7 +124,7 @@ TEST_P(BdpEstimatorRandomTest, GetEstimateRandomValues) { |
|
|
|
|
if (sample > max) max = sample; |
|
|
|
|
AddSample(&est, sample); |
|
|
|
|
if (i >= 3) { |
|
|
|
|
EXPECT_LE(GetEstimate(est), GPR_MAX(65536, 2 * NextPow2(max))) |
|
|
|
|
EXPECT_LE(est.EstimateBdp(), GPR_MAX(65536, 2 * NextPow2(max))) |
|
|
|
|
<< " min:" << min << " max:" << max << " sample:" << sample; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|