21 using namespace folly;
25 using duration = std::chrono::steady_clock::duration;
26 using time_point = std::chrono::steady_clock::time_point;
27 static constexpr
auto is_steady =
true;
38 TEST(SimpleQuantileEstimatorTest, EstimateQuantiles) {
40 for (
size_t i = 1;
i <= 100; ++
i) {
47 std::array<double, 5>{{.001, .01, .5, .99, .999}});
52 EXPECT_EQ(0.001, estimates.quantiles[0].first);
53 EXPECT_EQ(0.01, estimates.quantiles[1].first);
54 EXPECT_EQ(0.5, estimates.quantiles[2].first);
55 EXPECT_EQ(0.99, estimates.quantiles[3].first);
56 EXPECT_EQ(0.999, estimates.quantiles[4].first);
58 EXPECT_EQ(1, estimates.quantiles[0].second);
59 EXPECT_EQ(2.0 - 0.5, estimates.quantiles[1].second);
60 EXPECT_EQ(50.375, estimates.quantiles[2].second);
61 EXPECT_EQ(100.0 - 0.5, estimates.quantiles[3].second);
62 EXPECT_EQ(100, estimates.quantiles[4].second);
65 TEST(SlidingWindowQuantileEstimatorTest, EstimateQuantiles) {
67 for (
size_t i = 1;
i <= 100; ++
i) {
73 auto estimates = estimator.estimateQuantiles(
74 std::array<double, 5>{{.001, .01, .5, .99, .999}});
79 EXPECT_EQ(0.001, estimates.quantiles[0].first);
80 EXPECT_EQ(0.01, estimates.quantiles[1].first);
81 EXPECT_EQ(0.5, estimates.quantiles[2].first);
82 EXPECT_EQ(0.99, estimates.quantiles[3].first);
83 EXPECT_EQ(0.999, estimates.quantiles[4].first);
85 EXPECT_EQ(1, estimates.quantiles[0].second);
86 EXPECT_EQ(2.0 - 0.5, estimates.quantiles[1].second);
87 EXPECT_EQ(50.375, estimates.quantiles[2].second);
88 EXPECT_EQ(100.0 - 0.5, estimates.quantiles[3].second);
89 EXPECT_EQ(100, estimates.quantiles[4].second);
void addValue(double value, TimePoint now=ClockT::now())
#define EXPECT_EQ(val1, val2)
QuantileEstimates estimateQuantiles(Range< const double * > quantiles, TimePoint now=ClockT::now())
—— Concurrent Priority Queue Implementation ——
void addValue(double value, TimePoint now=ClockT::now())
std::chrono::steady_clock::duration duration
std::chrono::steady_clock::time_point time_point
TEST(SequencedExecutor, CPUThreadPoolExecutor)