ai改的全是bug 模块不清。要全部审核代码 然后再规范所有结构 以后不许让ai 随便加结构。不止是线程它写不好 啥也不行。从模块开始一个一个改然后 补全gmock测试。然后一步一步全部审核通过。ai写前写后都要让他给我计划审核。已经没token了
This commit is contained in:
@@ -88,8 +88,7 @@ struct Plot_Probe {
|
||||
};
|
||||
|
||||
struct Active_Plot {
|
||||
std::shared_ptr<web::Plot> plot{};
|
||||
web::Plot::Stream_Id stream{};
|
||||
std::string id{};
|
||||
std::shared_ptr<Plot_Probe> probe{};
|
||||
};
|
||||
|
||||
@@ -113,27 +112,27 @@ std::vector<Plot_Result> published_results{};
|
||||
? static_cast<double>(end - begin) / 1'000'000.0 : 0.0;
|
||||
}
|
||||
|
||||
[[nodiscard]] web::Plot_Input_Event make_event(
|
||||
[[nodiscard]] nlohmann::json make_event(
|
||||
Event_Type type, std::size_t plot_index, std::uint64_t batch) {
|
||||
web::Plot_Input_Event event{};
|
||||
event.type = type;
|
||||
event.time_milliseconds = static_cast<double>(steady_time_ns()) /
|
||||
1'000'000.0;
|
||||
event.position = {
|
||||
120.0 + static_cast<double>((batch * 13U + plot_index * 7U) % 400U),
|
||||
80.0 + static_cast<double>((batch * 11U + plot_index * 5U) % 240U)};
|
||||
event.global_position = event.position;
|
||||
event.button = Mouse_Button::left;
|
||||
event.buttons = type == Event_Type::pointer_release ? 0U : 1U;
|
||||
event.modifiers = Keyboard_Modifier::control;
|
||||
event.pixel_delta_x = 3.0;
|
||||
event.pixel_delta_y = (batch & 1U) == 0U ? 120.0 : -120.0;
|
||||
event.angle_delta_x = event.pixel_delta_x;
|
||||
event.angle_delta_y = event.pixel_delta_y;
|
||||
event.key = Key::space;
|
||||
event.native_key = 32;
|
||||
event.auto_repeat = (batch & 1U) != 0U;
|
||||
return event;
|
||||
const nlohmann::json position{
|
||||
{"x", 120.0 + static_cast<double>(
|
||||
(batch * 13U + plot_index * 7U) % 400U)},
|
||||
{"y", 80.0 + static_cast<double>(
|
||||
(batch * 11U + plot_index * 5U) % 240U)}};
|
||||
const auto wheel_delta = (batch & 1U) == 0U ? 120.0 : -120.0;
|
||||
return {
|
||||
{"type", magic_enum::enum_name(type)},
|
||||
{"time_milliseconds",
|
||||
static_cast<double>(steady_time_ns()) / 1'000'000.0},
|
||||
{"position", position}, {"global_position", position},
|
||||
{"button", "left"},
|
||||
{"buttons", type == Event_Type::pointer_release ? 0U : 1U},
|
||||
{"modifiers", static_cast<std::uint8_t>(Keyboard_Modifier::control)},
|
||||
{"pixel_delta_x", 3.0}, {"pixel_delta_y", wheel_delta},
|
||||
{"angle_delta_x", 3.0}, {"angle_delta_y", wheel_delta},
|
||||
{"key", "space"}, {"native_key", 32U},
|
||||
{"auto_repeat", (batch & 1U) != 0U}
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] const nlohmann::json& event_statistic(
|
||||
@@ -154,15 +153,12 @@ std::vector<Plot_Result> published_results{};
|
||||
return *found_statistic;
|
||||
}
|
||||
|
||||
void configure_manual_backend_plot(const std::shared_ptr<web::Plot>& plot) {
|
||||
const auto manual = plot->write_prop(
|
||||
void configure_manual_backend_plot(
|
||||
Control_Service& service, std::string_view id) {
|
||||
const auto manual = service.write_plot_property(id,
|
||||
"frame-analysis", "pacing_mode", "manual");
|
||||
if (!manual.value("success", false))
|
||||
throw std::runtime_error("failed to select manual frame pacing");
|
||||
const auto diagnostics_only = plot->write_prop(
|
||||
"frame-analysis", "pixel_delivery_enabled", false);
|
||||
if (!diagnostics_only.value("success", false))
|
||||
throw std::runtime_error("failed to disable backend pixel readback");
|
||||
}
|
||||
|
||||
[[nodiscard]] std::uint64_t correlation_id(
|
||||
@@ -283,7 +279,6 @@ public:
|
||||
|
||||
void run_event_latency(benchmark::State& state) {
|
||||
published_results.clear();
|
||||
auto service = Control_Service::create();
|
||||
const auto definitions = web::gallery_plot_definitions();
|
||||
std::vector<Active_Plot> active;
|
||||
active.reserve(definitions.size());
|
||||
@@ -294,18 +289,37 @@ void run_event_latency(benchmark::State& state) {
|
||||
if (configuration.three_d_only &&
|
||||
definition.dimension != web::Plot_Dimension::three_d)
|
||||
continue;
|
||||
auto plot = service->find_plot(definition.id);
|
||||
if (!plot)
|
||||
throw std::runtime_error(
|
||||
"Gallery plot is unavailable: " +
|
||||
std::string{definition.id});
|
||||
if (configuration.manual_policy)
|
||||
configure_manual_backend_plot(plot);
|
||||
auto probe = std::make_shared<Plot_Probe>();
|
||||
active.push_back({std::move(plot), 0, std::move(probe)});
|
||||
active.push_back({std::string{definition.id}, std::move(probe)});
|
||||
published_results.push_back({
|
||||
std::string{definition.id}, definition.dimension, {}});
|
||||
}
|
||||
auto service = Control_Service::create(Gallery_Output{
|
||||
.width = configuration.width,
|
||||
.height = configuration.height,
|
||||
.publish = [&active](
|
||||
std::string_view id,
|
||||
std::shared_ptr<const web::Gallery_Frame> frame) {
|
||||
const auto found = std::ranges::find(active, id,
|
||||
&Active_Plot::id);
|
||||
if (found == active.end() || !frame || !frame->pixels)
|
||||
return web::Gallery_Frame_Publication::ignored;
|
||||
const auto expected = found->probe->expected_correlation.load(
|
||||
std::memory_order_acquire);
|
||||
if (expected != 0 &&
|
||||
frame->pixels->correlation_id == expected) {
|
||||
std::uint64_t incomplete{};
|
||||
static_cast<void>(found->probe->completed_steady_ns.
|
||||
compare_exchange_strong(
|
||||
incomplete, steady_time_ns(),
|
||||
std::memory_order_release,
|
||||
std::memory_order_relaxed));
|
||||
}
|
||||
return web::Gallery_Frame_Publication::completed;
|
||||
}});
|
||||
if (configuration.manual_policy)
|
||||
for (const auto& item : active)
|
||||
configure_manual_backend_plot(*service, item.id);
|
||||
|
||||
std::string configuration_failure;
|
||||
if (configuration.manual_policy) {
|
||||
@@ -314,10 +328,20 @@ void run_event_latency(benchmark::State& state) {
|
||||
const auto deadline = Clock::now() + std::chrono::seconds{10};
|
||||
Task_Graph::corun_until([&] {
|
||||
const bool ready = std::ranges::all_of(
|
||||
active, [](const Active_Plot& item) {
|
||||
const auto diagnostics = item.plot->diagnostics();
|
||||
active, [&service](const Active_Plot& item) {
|
||||
const auto diagnostics =
|
||||
service->plot_diagnostics(item.id);
|
||||
if (!diagnostics.contains("frame_policy"))
|
||||
return false;
|
||||
const auto& policy = diagnostics.at("frame_policy").
|
||||
at("configuration");
|
||||
if (policy.at("mode") == "manual" &&
|
||||
policy.at("pixel_delivery_enabled").get<bool>()) {
|
||||
static_cast<void>(service->write_plot_property(
|
||||
item.id, "frame-analysis",
|
||||
"pixel_delivery_enabled", false));
|
||||
return false;
|
||||
}
|
||||
return policy.at("mode") == "manual" &&
|
||||
!policy.at("pixel_delivery_enabled").get<bool>();
|
||||
});
|
||||
@@ -327,7 +351,8 @@ void run_event_latency(benchmark::State& state) {
|
||||
"timed out applying manual backend frame policy";
|
||||
for (std::size_t index = 0; index < active.size(); ++index) {
|
||||
const auto& item = active[index];
|
||||
const auto diagnostics = item.plot->diagnostics();
|
||||
const auto diagnostics =
|
||||
service->plot_diagnostics(item.id);
|
||||
const auto& policy = diagnostics.at("frame_policy");
|
||||
const auto& policy_configuration =
|
||||
policy.at("configuration");
|
||||
@@ -352,30 +377,8 @@ void run_event_latency(benchmark::State& state) {
|
||||
if (!configuration_failure.empty())
|
||||
throw std::runtime_error(configuration_failure);
|
||||
|
||||
for (auto& item : active) {
|
||||
const auto probe = item.probe;
|
||||
item.stream = item.plot->subscribe(
|
||||
[probe](std::shared_ptr<const web::Plot_Stream_Frame> frame) {
|
||||
if (!frame || !frame->pixels)
|
||||
return web::Plot_Frame_Publication::ignored;
|
||||
const auto expected = probe->expected_correlation.load(
|
||||
std::memory_order_acquire);
|
||||
if (expected == 0 ||
|
||||
frame->pixels->correlation_id != expected)
|
||||
return web::Plot_Frame_Publication::completed;
|
||||
std::uint64_t incomplete{};
|
||||
static_cast<void>(
|
||||
probe->completed_steady_ns.compare_exchange_strong(
|
||||
incomplete, steady_time_ns(),
|
||||
std::memory_order_release,
|
||||
std::memory_order_relaxed));
|
||||
return web::Plot_Frame_Publication::completed;
|
||||
});
|
||||
item.plot->configure_stream(
|
||||
item.stream, configuration.width, configuration.height);
|
||||
}
|
||||
|
||||
for (auto& item : active) item.plot->reset_diagnostics();
|
||||
for (auto& item : active)
|
||||
service->reset_plot_diagnostics(item.id);
|
||||
std::vector<Batch_Timing> batch_timing(active.size());
|
||||
std::string failure;
|
||||
Task_Graph coordinator{"mcp.event-latency"};
|
||||
@@ -413,7 +416,7 @@ void run_event_latency(benchmark::State& state) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
item.plot->schedule_render(aethera::Frame_Request{
|
||||
service->request_frame(item.id, aethera::Frame_Request{
|
||||
.issued_at = Clock::now(),
|
||||
.sequence = correlation,
|
||||
.time_milliseconds =
|
||||
@@ -441,7 +444,8 @@ void run_event_latency(benchmark::State& state) {
|
||||
plot_index < active.size(); ++plot_index) {
|
||||
const auto completed = active[plot_index].probe->
|
||||
completed_steady_ns.load(std::memory_order_acquire);
|
||||
const auto diagnostics = active[plot_index].plot->diagnostics();
|
||||
const auto diagnostics = service->plot_diagnostics(
|
||||
active[plot_index].id);
|
||||
for (std::size_t event_index = 0;
|
||||
event_index < event_count; ++event_index) {
|
||||
auto& result = published_results[plot_index].
|
||||
@@ -506,8 +510,6 @@ void run_event_latency(benchmark::State& state) {
|
||||
catch (const std::exception& error) {
|
||||
state.SkipWithError(error.what());
|
||||
}
|
||||
|
||||
for (auto& item : active) item.plot->unsubscribe(item.stream);
|
||||
}
|
||||
|
||||
BENCHMARK(run_event_latency)->Iterations(1)->UseRealTime();
|
||||
|
||||
Reference in New Issue
Block a user