ai改的全是bug 模块不清。要全部审核代码 然后再规范所有结构 以后不许让ai 随便加结构。不止是线程它写不好 啥也不行。从模块开始一个一个改然后 补全gmock测试。然后一步一步全部审核通过。ai写前写后都要让他给我计划审核。已经没token了

This commit is contained in:
2026-08-30 01:45:08 +08:00
parent 7216a1703f
commit cb6a73bc80
43 changed files with 1740 additions and 2264 deletions
+51 -32
View File
@@ -20,6 +20,7 @@
#include <string>
#include <string_view>
#include <vector>
#include <unordered_map>
namespace aethera::web::event_latency_benchmarks {
namespace {
@@ -89,7 +90,7 @@ struct Media_Probe {
};
struct Active_Plot {
std::shared_ptr<Plot> plot{};
std::string id{};
std::shared_ptr<Graph_WebSocket> input{};
std::shared_ptr<media::Gallery_Video_Stream> video{};
media::Gallery_Video_Stream::Stream_Id video_subscription{};
@@ -131,8 +132,9 @@ std::vector<Plot_Result> published_results{};
}
[[nodiscard]] std::uint64_t event_statistic_count(
const std::shared_ptr<Plot>& plot, Event_Type type) {
const auto diagnostics = plot->diagnostics();
const mcp::Control_Service& control, std::string_view id,
Event_Type type) {
const auto diagnostics = control.plot_diagnostics(id);
const auto* statistic = find_event_statistic(
diagnostics, type, "total_ms");
return statistic ? statistic->value("count", 0ULL) : 0ULL;
@@ -181,21 +183,16 @@ std::vector<Plot_Result> published_results{};
}.dump();
}
void configure_plot(const std::shared_ptr<Plot>& plot) {
if (!plot) throw std::invalid_argument("web benchmark Plot is null");
if (!plot->write_prop(
void configure_plot(mcp::Control_Service& control, std::string_view id) {
if (!control.write_plot_property(id,
"frame-analysis", "pacing_mode", "manual").value(
"success", false))
throw std::runtime_error("failed to select manual Plot policy");
if (!plot->write_prop(
"frame-analysis", "pixel_delivery_enabled", true).value(
"success", false))
throw std::runtime_error("failed to enable Plot pixel delivery");
}
[[nodiscard]] bool manual_pixel_policy_applied(
const std::shared_ptr<Plot>& plot) {
const auto diagnostics = plot->diagnostics();
const mcp::Control_Service& control, std::string_view id) {
const auto diagnostics = control.plot_diagnostics(id);
const auto policy = diagnostics.find("frame_policy");
if (policy == diagnostics.end() || !policy->is_object()) return false;
const auto state = policy->find("configuration");
@@ -300,19 +297,26 @@ void print_results() {
void run_event_latency(benchmark::State& state) {
published_results.clear();
auto control = mcp::Control_Service::create();
std::vector<Active_Plot> active;
try {
const auto definitions = selected_definitions();
auto control_slot = std::make_shared<std::atomic<
std::shared_ptr<mcp::Control_Service>>>();
auto videos = std::make_shared<std::unordered_map<
std::string, std::shared_ptr<media::Gallery_Video_Stream>>>();
active.reserve(definitions.size());
published_results.reserve(definitions.size());
for (const auto& definition : definitions) {
auto plot = control->find_plot(definition.id);
configure_plot(plot);
const auto id = std::string{definition.id};
auto probe = std::make_shared<Media_Probe>();
auto video = media::Gallery_Video_Stream::create({
{std::string{definition.id}, plot}});
{id, [control_slot, id](Frame_Publication_Feedback feedback) {
if (const auto control = control_slot->load())
control->submit_publication_feedback(
id, std::move(feedback));
}}});
videos->emplace(id, video);
const auto video_subscription = video->subscribe(
"web-event-latency-" + std::string{definition.id},
[probe](media::Gallery_Stream_Frame frame) {
@@ -328,25 +332,38 @@ void run_event_latency(benchmark::State& state) {
},
[] { return true; },
[] { return nlohmann::json::object(); });
auto input = std::make_shared<Graph_WebSocket>(
plot, [](std::string) {});
input->start();
input->receive(nlohmann::json{
{"kind", "stream"},
{"viewport", {
{"width", configuration.width},
{"height", configuration.height}}}
}.dump());
active.push_back({std::move(plot), std::move(input),
active.push_back({id, {},
std::move(video), video_subscription,
std::move(probe)});
published_results.push_back({
std::string{definition.id}, definition.dimension, {}});
}
auto control = mcp::Control_Service::create(mcp::Gallery_Output{
.width = configuration.width,
.height = configuration.height,
.publish = [videos](
std::string_view id,
std::shared_ptr<const Gallery_Frame> frame) {
const auto found = videos->find(std::string{id});
return found == videos->end()
? Gallery_Frame_Publication::ignored
: found->second->accept_frame(id, std::move(frame));
}});
control_slot->store(control);
for (auto& item : active) {
configure_plot(*control, item.id);
item.input = std::make_shared<Graph_WebSocket>(control, item.id);
item.input->start();
item.input->receive(nlohmann::json{
{"kind", "stream"},
{"viewport", {{"width", configuration.width},
{"height", configuration.height}}}
}.dump());
}
cooperatively_wait("manual Plot policies", [&] {
return std::ranges::all_of(active, [](const Active_Plot& item) {
return manual_pixel_policy_applied(item.plot);
return std::ranges::all_of(active, [&control](const Active_Plot& item) {
return manual_pixel_policy_applied(*control, item.id);
});
}, std::chrono::seconds{10});
@@ -364,7 +381,8 @@ void run_event_latency(benchmark::State& state) {
return false;
return true;
}, std::chrono::seconds{60});
for (auto& item : active) item.plot->reset_diagnostics();
for (auto& item : active)
control->reset_plot_diagnostics(item.id);
std::vector<Event_Timing> timings(active.size());
std::string failure;
@@ -383,7 +401,7 @@ void run_event_latency(benchmark::State& state) {
item.probe->frame_count.load(
std::memory_order_acquire);
timing.statistic_count_before = event_statistic_count(
item.plot, type);
*control, item.id, type);
const auto message = input_message(
type, plot_index, sample);
timing.submitted_unix_ns = system_time_ns();
@@ -403,7 +421,7 @@ void run_event_latency(benchmark::State& state) {
frame_count.load(std::memory_order_acquire) >
timings[index].encoded_count_before;
const auto observed = event_statistic_count(
active[index].plot, type) >
*control, active[index].id, type) >
timings[index].statistic_count_before;
complete = complete && encoded && observed;
}
@@ -425,7 +443,8 @@ void run_event_latency(benchmark::State& state) {
published_time_unix_ns.load(
std::memory_order_acquire);
const auto diagnostics =
active[plot_index].plot->diagnostics();
control->plot_diagnostics(
active[plot_index].id);
auto& result = published_results[plot_index].
events[event_index];
result.websocket_receive_ms.add(milliseconds(