优化了 还是卡

This commit is contained in:
2026-08-25 21:44:57 +08:00
parent 4f3430e3ad
commit 65799cfc2a
21 changed files with 850 additions and 1224 deletions
@@ -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);
}
}
}
}