优化了 还是卡
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
#include "web_server/src/Page_Session.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace aethera::web {
|
||||
TEST(Page_Session, New_Page_Displaces_Previous_Page_Without_Waiting_For_Close) {
|
||||
Page_Session session;
|
||||
const auto first_token = session.begin_page();
|
||||
std::size_t displaced{};
|
||||
const auto first_connection = session.attach(
|
||||
first_token, [&displaced] { ++displaced; });
|
||||
ASSERT_TRUE(first_connection.has_value());
|
||||
|
||||
const auto second_token = session.begin_page();
|
||||
EXPECT_NE(first_token, second_token);
|
||||
EXPECT_EQ(displaced, 1U);
|
||||
EXPECT_EQ(session.attach(first_token, [] {}).error(),
|
||||
Page_Session::Attach_Result::stale_session);
|
||||
|
||||
const auto second_connection = session.attach(second_token, [] {});
|
||||
EXPECT_TRUE(second_connection.has_value());
|
||||
session.detach(*first_connection);
|
||||
session.detach(*second_connection);
|
||||
}
|
||||
|
||||
TEST(Page_Session, One_Page_Can_Attach_All_Of_Its_Connections) {
|
||||
Page_Session session;
|
||||
const auto token = session.begin_page();
|
||||
const auto gallery = session.attach(token, [] {});
|
||||
const auto plot = session.attach(token, [] {});
|
||||
ASSERT_TRUE(gallery.has_value());
|
||||
ASSERT_TRUE(plot.has_value());
|
||||
EXPECT_NE(*gallery, *plot);
|
||||
session.detach(*gallery);
|
||||
session.detach(*plot);
|
||||
}
|
||||
}
|
||||
@@ -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