ai改的全是bug 模块不清。要全部审核代码 然后再规范所有结构 以后不许让ai 随便加结构。不止是线程它写不好 啥也不行。从模块开始一个一个改然后 补全gmock测试。然后一步一步全部审核通过。ai写前写后都要让他给我计划审核。已经没token了
This commit is contained in:
@@ -176,25 +176,27 @@ struct Concurrent_Workload_State {
|
||||
std::uint64_t sequence) {
|
||||
Plot_Input_Request request;
|
||||
request.plot = configuration.plot_ids[plot_index];
|
||||
request.event.time_milliseconds = 1'000.0 +
|
||||
static_cast<double>(sequence) *
|
||||
(1'000.0 / static_cast<double>(configuration.input_rate_hz));
|
||||
request.event.position = {
|
||||
360.0 + static_cast<double>(
|
||||
static_cast<std::int64_t>((sequence + plot_index * 7U) % 121U) - 60),
|
||||
210.0 + static_cast<double>(
|
||||
static_cast<std::int64_t>((sequence * 3U + plot_index * 11U) % 81U) - 40)};
|
||||
request.event.global_position = request.event.position;
|
||||
const nlohmann::json position{
|
||||
{"x", 360.0 + static_cast<double>(
|
||||
static_cast<std::int64_t>((sequence + plot_index * 7U) % 121U) - 60)},
|
||||
{"y", 210.0 + static_cast<double>(
|
||||
static_cast<std::int64_t>((sequence * 3U + plot_index * 11U) % 81U) - 40)}};
|
||||
request.event = {
|
||||
{"time_milliseconds", 1'000.0 + static_cast<double>(sequence) *
|
||||
(1'000.0 / static_cast<double>(configuration.input_rate_hz))},
|
||||
{"position", position}, {"global_position", position}
|
||||
};
|
||||
if (workload == Input_Workload::wheel ||
|
||||
(workload == Input_Workload::mixed && (plot_index & 1U) != 0U)) {
|
||||
request.event.type = Event_Type::wheel;
|
||||
request.event.pixel_delta_y = (sequence & 1U) != 0U ? 120.0 : -120.0;
|
||||
request.event.angle_delta_y = request.event.pixel_delta_y;
|
||||
const auto delta = (sequence & 1U) != 0U ? 120.0 : -120.0;
|
||||
request.event["type"] = "wheel";
|
||||
request.event["pixel_delta_y"] = delta;
|
||||
request.event["angle_delta_y"] = delta;
|
||||
return request;
|
||||
}
|
||||
request.event.type = Event_Type::pointer_move;
|
||||
request.event.button = Mouse_Button::left;
|
||||
request.event.buttons = 1;
|
||||
request.event["type"] = "pointer_move";
|
||||
request.event["button"] = "left";
|
||||
request.event["buttons"] = 1;
|
||||
return request;
|
||||
}
|
||||
|
||||
@@ -204,50 +206,40 @@ public:
|
||||
if (shared_service) {
|
||||
service = shared_service;
|
||||
workload = shared_workload;
|
||||
plots = shared_plots;
|
||||
streams = shared_streams;
|
||||
return;
|
||||
}
|
||||
shared_service = Control_Service::create();
|
||||
shared_workload = std::make_shared<Concurrent_Workload_State>();
|
||||
shared_workload->completed.reserve(configuration.plot_ids.size());
|
||||
shared_plots.reserve(configuration.plot_ids.size());
|
||||
shared_streams.reserve(configuration.plot_ids.size());
|
||||
for (std::size_t index = 0; index < configuration.plot_ids.size();
|
||||
++index) {
|
||||
auto plot = shared_service->find_plot(configuration.plot_ids[index]);
|
||||
if (!plot)
|
||||
throw std::logic_error("configured benchmark Plot is unavailable");
|
||||
auto completed = std::make_shared<std::atomic_uint64_t>(0);
|
||||
shared_workload->completed.push_back(completed);
|
||||
const auto stream = plot->subscribe(
|
||||
[completed = std::move(completed)](
|
||||
std::shared_ptr<const web::Plot_Stream_Frame> frame) {
|
||||
if (!frame || !frame->pixels)
|
||||
return web::Plot_Frame_Publication::ignored;
|
||||
completed->fetch_add(
|
||||
1, std::memory_order_relaxed);
|
||||
return web::Plot_Frame_Publication::completed;
|
||||
});
|
||||
plot->configure_stream(
|
||||
stream, configuration.width, configuration.height);
|
||||
shared_plots.push_back(std::move(plot));
|
||||
shared_streams.push_back(stream);
|
||||
}
|
||||
shared_service = Control_Service::create(Gallery_Output{
|
||||
.width = configuration.width,
|
||||
.height = configuration.height,
|
||||
.publish = [workload = shared_workload](
|
||||
std::string_view id,
|
||||
std::shared_ptr<const web::Gallery_Frame> frame) {
|
||||
const auto found = std::ranges::find(
|
||||
configuration.plot_ids, id);
|
||||
if (found == configuration.plot_ids.end() || !frame ||
|
||||
!frame->pixels)
|
||||
return web::Gallery_Frame_Publication::ignored;
|
||||
const auto index = static_cast<std::size_t>(
|
||||
found - configuration.plot_ids.begin());
|
||||
workload->completed[index]->fetch_add(
|
||||
1, std::memory_order_relaxed);
|
||||
return web::Gallery_Frame_Publication::completed;
|
||||
}});
|
||||
service = shared_service;
|
||||
workload = shared_workload;
|
||||
plots = shared_plots;
|
||||
streams = shared_streams;
|
||||
}
|
||||
|
||||
void TearDown(const benchmark::State&) override {}
|
||||
|
||||
static void shutdown() {
|
||||
if (!shared_workload) return;
|
||||
for (std::size_t index = 0; index < shared_plots.size(); ++index)
|
||||
shared_plots[index]->unsubscribe(shared_streams[index]);
|
||||
shared_plots.clear();
|
||||
shared_streams.clear();
|
||||
shared_service.reset();
|
||||
shared_workload.reset();
|
||||
}
|
||||
@@ -264,8 +256,8 @@ protected:
|
||||
auto request = concurrent_input_request(
|
||||
input, plot_index, sequence);
|
||||
if (pointer_type) {
|
||||
request.event.type = *pointer_type;
|
||||
request.event.buttons = *pointer_type == Event_Type::pointer_release
|
||||
request.event["type"] = magic_enum::enum_name(*pointer_type);
|
||||
request.event["buttons"] = *pointer_type == Event_Type::pointer_release
|
||||
? 0 : 1;
|
||||
}
|
||||
const auto result = service->call_tool(
|
||||
@@ -279,9 +271,9 @@ protected:
|
||||
const auto input = configuration.input;
|
||||
for (auto& count : workload->completed)
|
||||
count->store(0, std::memory_order_relaxed);
|
||||
for (const auto& plot : plots) {
|
||||
plot->reset_diagnostics();
|
||||
plot->request_taskflow_trace(1);
|
||||
for (const auto id : configuration.plot_ids) {
|
||||
service->reset_plot_diagnostics(id);
|
||||
service->request_plot_taskflow_trace(id, 1);
|
||||
}
|
||||
if (input == Input_Workload::drag || input == Input_Workload::mixed) {
|
||||
if (!submit_input_batch(
|
||||
@@ -333,7 +325,8 @@ protected:
|
||||
std::uint64_t total_completed{};
|
||||
double minimum_fps = std::numeric_limits<double>::max();
|
||||
double maximum_fps{};
|
||||
for (std::size_t index = 0; index < plots.size(); ++index) {
|
||||
for (std::size_t index = 0;
|
||||
index < configuration.plot_ids.size(); ++index) {
|
||||
const auto count = workload->completed[index]->load(
|
||||
std::memory_order_relaxed);
|
||||
total_completed += count;
|
||||
@@ -341,7 +334,8 @@ protected:
|
||||
? static_cast<double>(count) / elapsed_seconds : 0.0;
|
||||
minimum_fps = std::min(minimum_fps, fps);
|
||||
maximum_fps = std::max(maximum_fps, fps);
|
||||
const auto diagnostics = plots[index]->diagnostics();
|
||||
const auto diagnostics = service->plot_diagnostics(
|
||||
configuration.plot_ids[index]);
|
||||
const auto& policy = diagnostics.at("frame_policy");
|
||||
const auto prefix = std::string{configuration.plot_ids[index]} + "/";
|
||||
state.counters[prefix + "fps"] = fps;
|
||||
@@ -520,8 +514,10 @@ protected:
|
||||
double longest_sampled_busy_ms{};
|
||||
std::string longest_sampled_busy_node;
|
||||
std::string longest_sampled_busy_plot;
|
||||
for (std::size_t plot_index = 0; plot_index < plots.size(); ++plot_index) {
|
||||
const auto trace = plots[plot_index]->taskflow_trace();
|
||||
for (std::size_t plot_index = 0;
|
||||
plot_index < configuration.plot_ids.size(); ++plot_index) {
|
||||
const auto trace = service->plot_taskflow_trace(
|
||||
configuration.plot_ids[plot_index]);
|
||||
if (!trace.value("complete", false)) continue;
|
||||
for (const auto& frame : trace.at("frames"))
|
||||
for (const auto& execution : frame.at("executions")) {
|
||||
@@ -553,12 +549,8 @@ protected:
|
||||
private:
|
||||
inline static std::shared_ptr<Control_Service> shared_service{};
|
||||
inline static std::shared_ptr<Concurrent_Workload_State> shared_workload{};
|
||||
inline static std::vector<std::shared_ptr<web::Plot>> shared_plots{};
|
||||
inline static std::vector<web::Plot::Stream_Id> shared_streams{};
|
||||
std::shared_ptr<Control_Service> service{};
|
||||
std::shared_ptr<Concurrent_Workload_State> workload{};
|
||||
std::vector<std::shared_ptr<web::Plot>> plots{};
|
||||
std::vector<web::Plot::Stream_Id> streams{};
|
||||
};
|
||||
|
||||
BENCHMARK_DEFINE_F(Configured_Plots, Run)(benchmark::State& state) {
|
||||
|
||||
Reference in New Issue
Block a user