重定义模块职责
This commit is contained in:
@@ -31,6 +31,8 @@ struct Configuration {
|
||||
std::uint32_t width{720};
|
||||
std::uint32_t height{420};
|
||||
std::uint32_t samples{12};
|
||||
bool three_d_only{};
|
||||
bool manual_policy{true};
|
||||
};
|
||||
|
||||
struct Summary {
|
||||
@@ -289,12 +291,16 @@ void run_event_latency(benchmark::State& state) {
|
||||
|
||||
try {
|
||||
for (const auto& definition : definitions) {
|
||||
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});
|
||||
configure_manual_backend_plot(plot);
|
||||
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)});
|
||||
published_results.push_back({
|
||||
@@ -302,8 +308,9 @@ void run_event_latency(benchmark::State& state) {
|
||||
}
|
||||
|
||||
std::string configuration_failure;
|
||||
Task_Graph configuration_barrier{"mcp.event-latency.configure"};
|
||||
configuration_barrier.add("await.manual-policy", [&] {
|
||||
if (configuration.manual_policy) {
|
||||
Task_Graph configuration_barrier{"mcp.event-latency.configure"};
|
||||
configuration_barrier.add("await.manual-policy", [&] {
|
||||
const auto deadline = Clock::now() + std::chrono::seconds{10};
|
||||
Task_Graph::corun_until([&] {
|
||||
const bool ready = std::ranges::all_of(
|
||||
@@ -318,10 +325,30 @@ void run_event_latency(benchmark::State& state) {
|
||||
if (Clock::now() < deadline) return false;
|
||||
configuration_failure =
|
||||
"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& policy = diagnostics.at("frame_policy");
|
||||
const auto& policy_configuration =
|
||||
policy.at("configuration");
|
||||
if (policy_configuration.at("mode") == "manual")
|
||||
continue;
|
||||
const auto& lifecycle = policy.at("lifecycle");
|
||||
configuration_failure += "\n " +
|
||||
published_results[index].id +
|
||||
": mode=" +
|
||||
policy_configuration.at("mode").get<std::string>() +
|
||||
", lifecycle=" +
|
||||
lifecycle.at("state").get<std::string>() +
|
||||
", active=" + std::to_string(
|
||||
lifecycle.at("active_frame_count").
|
||||
get<std::size_t>());
|
||||
}
|
||||
return true;
|
||||
});
|
||||
});
|
||||
aethera::detail::run_taskflow(configuration_barrier);
|
||||
});
|
||||
aethera::detail::run_taskflow(configuration_barrier);
|
||||
}
|
||||
if (!configuration_failure.empty())
|
||||
throw std::runtime_error(configuration_failure);
|
||||
|
||||
@@ -500,6 +527,8 @@ BENCHMARK(run_event_latency)->Iterations(1)->UseRealTime();
|
||||
constexpr std::string_view samples_prefix{
|
||||
"--aethera_event_samples="};
|
||||
constexpr std::string_view size_prefix{"--aethera_size="};
|
||||
constexpr std::string_view plots_prefix{"--aethera_plots="};
|
||||
constexpr std::string_view policy_prefix{"--aethera_policy="};
|
||||
if (argument.starts_with(samples_prefix)) {
|
||||
if (!parse_unsigned(argument.substr(samples_prefix.size()),
|
||||
configuration.samples) ||
|
||||
@@ -523,6 +552,26 @@ BENCHMARK(run_event_latency)->Iterations(1)->UseRealTime();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (argument.starts_with(plots_prefix)) {
|
||||
const auto value = argument.substr(plots_prefix.size());
|
||||
if (value == "all") configuration.three_d_only = false;
|
||||
else if (value == "3d") configuration.three_d_only = true;
|
||||
else {
|
||||
std::cerr << "--aethera_plots requires all or 3d\n";
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (argument.starts_with(policy_prefix)) {
|
||||
const auto value = argument.substr(policy_prefix.size());
|
||||
if (value == "manual") configuration.manual_policy = true;
|
||||
else if (value == "current") configuration.manual_policy = false;
|
||||
else {
|
||||
std::cerr << "--aethera_policy requires manual or current\n";
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
argv[retained++] = argv[index];
|
||||
}
|
||||
argc = retained;
|
||||
@@ -538,7 +587,14 @@ int main(int argc, char** argv) {
|
||||
aethera::initialize_runtime({});
|
||||
benchmark::Initialize(&argc, argv);
|
||||
if (benchmark::ReportUnrecognizedArguments(argc, argv)) return 2;
|
||||
benchmark::AddCustomContext("aethera_plots", "all");
|
||||
benchmark::AddCustomContext(
|
||||
"aethera_plots",
|
||||
aethera::mcp::event_latency_benchmarks::configuration.three_d_only
|
||||
? "3d" : "all");
|
||||
benchmark::AddCustomContext(
|
||||
"aethera_policy",
|
||||
aethera::mcp::event_latency_benchmarks::configuration.manual_policy
|
||||
? "manual" : "current");
|
||||
benchmark::AddCustomContext(
|
||||
"aethera_event_samples",
|
||||
std::to_string(
|
||||
|
||||
Reference in New Issue
Block a user