优化了 还是卡
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <frame_statistics.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
||||
namespace aethera::web {
|
||||
@@ -52,4 +53,18 @@ TEST(Sliding_Statistics, Estimates_Quantiles_Without_Growing_The_Window) {
|
||||
EXPECT_NEAR(state.p95, 950.0, 15.0);
|
||||
EXPECT_NEAR(state.p99, 990.0, 15.0);
|
||||
}
|
||||
|
||||
TEST(Sliding_Statistics, Keeps_Approximate_Quantiles_Ordered_For_Nonstationary_Input) {
|
||||
Sliding_Statistics statistics{16};
|
||||
for (std::size_t phase = 0; phase < 200; ++phase) {
|
||||
const double baseline = phase % 2 == 0 ? 1'000'000.0 : -1'000'000.0;
|
||||
for (std::size_t sample = 0; sample < 17; ++sample) {
|
||||
const auto state = statistics.submit(
|
||||
baseline + static_cast<double>(sample * sample));
|
||||
EXPECT_TRUE(std::isfinite(state.trimmed_average));
|
||||
EXPECT_LE(state.p50, state.p95);
|
||||
EXPECT_LE(state.p95, state.p99);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user