From 0906a63dfa64c6869754a24b06b06a542315e7c3 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 26 Sep 2025 16:53:04 +0200 Subject: [PATCH] DPL GUI: simplify and speed up * Avoid cumbersome retrivial of the lifetime * No need to create a string just to format it. --- Framework/GUISupport/CMakeLists.txt | 1 + .../src/FrameworkGUIDataRelayerUsage.cxx | 2 +- .../src/FrameworkGUIDeviceInspector.cxx | 18 +++------ Framework/GUISupport/src/InspectorHelpers.cxx | 40 +++++++++++++++++++ Framework/GUISupport/src/InspectorHelpers.h | 29 +------------- 5 files changed, 50 insertions(+), 40 deletions(-) create mode 100644 Framework/GUISupport/src/InspectorHelpers.cxx diff --git a/Framework/GUISupport/CMakeLists.txt b/Framework/GUISupport/CMakeLists.txt index 61519c21dc20c..8e67da3e53e15 100644 --- a/Framework/GUISupport/CMakeLists.txt +++ b/Framework/GUISupport/CMakeLists.txt @@ -20,6 +20,7 @@ o2_add_library(FrameworkGUISupport src/PaletteHelpers.cxx src/SpyService.cxx src/SpyServiceHelpers.cxx + src/InspectorHelpers.cxx PRIVATE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}/src PUBLIC_LINK_LIBRARIES O2::Framework AliceO2::DebugGUI) diff --git a/Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.cxx b/Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.cxx index c39e268fa90a7..1d3b4f24ea34c 100644 --- a/Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.cxx +++ b/Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.cxx @@ -233,7 +233,7 @@ void displayDataRelayer(DeviceMetricsInfo const& /*metrics*/, continue; } if (i == (size_t)row) { - ImGui::Text("%d %.*s (%s)", row, int(end - input), input, InspectorHelpers::getLifeTimeStr(spec.inputs[i].matcher.lifetime).c_str()); + ImGui::Text("%d %.*s (%s)", row, int(end - input), input, InspectorHelpers::getLifeTimeStr(spec.inputs[i].matcher.lifetime)); break; } ++i; diff --git a/Framework/GUISupport/src/FrameworkGUIDeviceInspector.cxx b/Framework/GUISupport/src/FrameworkGUIDeviceInspector.cxx index 9b2a13c07987d..b8c9cc50f0770 100644 --- a/Framework/GUISupport/src/FrameworkGUIDeviceInspector.cxx +++ b/Framework/GUISupport/src/FrameworkGUIDeviceInspector.cxx @@ -79,7 +79,8 @@ void deviceStateTable(DataProcessingStates const& states) } } -void deviceInfoTable(char const* label, ProcessingStateId id, DataProcessingStates const& states, std::variant, std::vector> routes, DeviceMetricsInfo const& metrics) +template +void deviceInfoTable(char const* label, ProcessingStateId id, DataProcessingStates const& states, Routes const& routes, DeviceMetricsInfo const& metrics) { // Find the state spec associated to data_queries auto& view = states.statesViews[(int)id]; @@ -95,17 +96,10 @@ void deviceInfoTable(char const* label, ProcessingStateId id, DataProcessingStat if ((end - input) == 0) { continue; } - auto getLifetime = [&routes, &i]() -> Lifetime { - if (std::get_if>(&routes)) { - return std::get>(routes)[i].matcher.lifetime; - } else { - return std::get>(routes)[i].matcher.lifetime; - } - }; - ImGui::Text("%zu: %.*s (%s)", i, int(end - input), input, InspectorHelpers::getLifeTimeStr(getLifetime()).c_str()); + ImGui::Text("%zu: %.*s (%s)", i, int(end - input), input, InspectorHelpers::getLifeTimeStr(routes[i].matcher.lifetime)); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); - ImGui::Text("%zu: %.*s (%s)", i, int(end - input), input, InspectorHelpers::getLifeTimeStr(getLifetime()).c_str()); + ImGui::Text("%zu: %.*s (%s)", i, int(end - input), input, InspectorHelpers::getLifeTimeStr(routes[i].matcher.lifetime)); ImGui::EndTooltip(); } input = end + 1; @@ -346,8 +340,8 @@ void displayDeviceInspector(DeviceSpec const& spec, } deviceStateTable(states); - deviceInfoTable("Inputs:", ProcessingStateId::DATA_QUERIES, states, std::variant, std::vector>(spec.inputs), metrics); - deviceInfoTable("Outputs:", ProcessingStateId::OUTPUT_MATCHERS, states, std::variant, std::vector>(spec.outputs), metrics); + deviceInfoTable("Inputs:", ProcessingStateId::DATA_QUERIES, states, spec.inputs, metrics); + deviceInfoTable("Outputs:", ProcessingStateId::OUTPUT_MATCHERS, states, spec.outputs, metrics); configurationTable(info.currentConfig, info.currentProvenance); optionsTable("Workflow Options", metadata.workflowOptions, control); if (ImGui::CollapsingHeader("Labels", ImGuiTreeNodeFlags_DefaultOpen)) { diff --git a/Framework/GUISupport/src/InspectorHelpers.cxx b/Framework/GUISupport/src/InspectorHelpers.cxx new file mode 100644 index 0000000000000..23e74c964e531 --- /dev/null +++ b/Framework/GUISupport/src/InspectorHelpers.cxx @@ -0,0 +1,40 @@ +// Copyright 2019-2025 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include "InspectorHelpers.h" + +namespace o2::framework +{ +char const* InspectorHelpers::getLifeTimeStr(Lifetime lifetime) +{ + switch (lifetime) { + case Lifetime::Timeframe: + return "Timeframe"; + case Lifetime::Condition: + return "Condition"; + case Lifetime::Sporadic: + return "Sporadic"; + case Lifetime::Transient: + return "Transient"; + case Lifetime::Timer: + return "Timer"; + case Lifetime::Enumeration: + return "Enumeration"; + case Lifetime::Signal: + return "Signal"; + case Lifetime::Optional: + return "Optional"; + case Lifetime::OutOfBand: + return "OutOfBand"; + } + return "none"; +}; +} // namespace o2::framework diff --git a/Framework/GUISupport/src/InspectorHelpers.h b/Framework/GUISupport/src/InspectorHelpers.h index 124c714f54df5..193486fc91dbc 100644 --- a/Framework/GUISupport/src/InspectorHelpers.h +++ b/Framework/GUISupport/src/InspectorHelpers.h @@ -1,4 +1,4 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// Copyright 2019-2025 CERN and copyright holders of ALICE O2. // See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. // All rights not expressly granted are reserved. // @@ -11,8 +11,6 @@ #ifndef O2_FRAMEWORK_INSPECTORHELPERS_H_ #define O2_FRAMEWORK_INSPECTORHELPERS_H_ -#include - #include "Framework/Lifetime.h" namespace o2::framework @@ -20,30 +18,7 @@ namespace o2::framework /// A helper class for inpsection of device information struct InspectorHelpers { - static const std::string getLifeTimeStr(Lifetime lifetime) - { - switch (lifetime) { - case Lifetime::Timeframe: - return "Timeframe"; - case Lifetime::Condition: - return "Condition"; - case Lifetime::Sporadic: - return "Sporadic"; - case Lifetime::Transient: - return "Transient"; - case Lifetime::Timer: - return "Timer"; - case Lifetime::Enumeration: - return "Enumeration"; - case Lifetime::Signal: - return "Signal"; - case Lifetime::Optional: - return "Optional"; - case Lifetime::OutOfBand: - return "OutOfBand"; - } - return "none"; - }; + static const char* getLifeTimeStr(Lifetime lifetime); }; } // namespace o2::framework