Skip to content

Commit 2fe57ff

Browse files
committed
DPL GUI: better tick labels for X axis
1 parent 2c0e39b commit 2fe57ff

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

Framework/Core/include/Framework/DriverInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ struct DriverInfo {
118118
std::vector<CallbacksPolicy> callbacksPolicies;
119119
/// The offset at which the process was started.
120120
uint64_t startTime;
121+
/// The actual time in milliseconds from epoch at which the process was started.
122+
uint64_t startTimeMsFromEpoch;
121123
/// The optional timeout after which the driver will request
122124
/// all the children to quit.
123125
double timeout;

Framework/Core/src/runDataProcessing.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2815,6 +2815,9 @@ int doMain(int argc, char** argv, o2::framework::WorkflowSpec const& workflow,
28152815
}
28162816
driverInfo.minFailureLevel = varmap["min-failure-level"].as<LogParsingHelpers::LogLevel>();
28172817
driverInfo.startTime = uv_hrtime();
2818+
driverInfo.startTimeMsFromEpoch = std::chrono::duration_cast<std::chrono::milliseconds>(
2819+
std::chrono::system_clock::now().time_since_epoch())
2820+
.count();
28182821
driverInfo.timeout = varmap["timeout"].as<uint64_t>();
28192822
driverInfo.deployHostname = varmap["hostname"].as<std::string>();
28202823
driverInfo.resources = varmap["resources"].as<std::string>();

Framework/GUISupport/src/FrameworkGUIDebugger.cxx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,23 @@ void displaySparks(
341341
ImGui::EndTable();
342342
}
343343

344+
int formatTimeSinceStart(double value, char* buff, int size, void* user_data)
345+
{
346+
auto* startTime = (int64_t*)user_data;
347+
if (value - *startTime < 0) {
348+
buff[0] = '\0';
349+
return 0;
350+
}
351+
int64_t seconds = (value - *startTime) / 1000;
352+
int64_t minutes = seconds / 60;
353+
return snprintf(buff, size, "%02lld:%02lld", minutes, seconds % 60);
354+
}
355+
344356
void displayDeviceMetrics(const char* label,
345357
size_t rangeBegin, size_t rangeEnd, size_t bins, MetricsDisplayStyle displayType,
346358
std::vector<MetricDisplayState>& state,
347-
AllMetricsStore const& metricStore)
359+
AllMetricsStore const& metricStore,
360+
DriverInfo const& driverInfo)
348361
{
349362
std::vector<void*> metricsToDisplay;
350363
std::vector<const char*> deviceNames;
@@ -493,6 +506,7 @@ void displayDeviceMetrics(const char* label,
493506
case MetricsDisplayStyle::Histos:
494507
if (ImPlot::BeginPlot("##Some plot")) {
495508
ImPlot::SetupAxes("time", "value");
509+
ImPlot::SetupAxisFormat(ImAxis_X1, formatTimeSinceStart, (void*)&driverInfo.startTimeMsFromEpoch);
496510
for (size_t pi = 0; pi < metricsToDisplay.size(); ++pi) {
497511
ImGui::PushID(pi);
498512
auto data = (const MultiplotData*)metricsToDisplay[pi];
@@ -510,6 +524,7 @@ void displayDeviceMetrics(const char* label,
510524
//ImPlot::FitNextPlotAxes(true, true, true, true);
511525
if (ImPlot::BeginPlot("##Some plot", {-1, -1}, axisFlags)) {
512526
ImPlot::SetupAxes("time", "value", xAxisFlags, yAxisFlags);
527+
ImPlot::SetupAxisFormat(ImAxis_X1, formatTimeSinceStart, (void*)&driverInfo.startTimeMsFromEpoch);
513528
for (size_t pi = 0; pi < metricsToDisplay.size(); ++pi) {
514529
ImGui::PushID(pi);
515530
auto data = (const MultiplotData*)metricsToDisplay[pi];
@@ -891,7 +906,7 @@ void displayMetrics(gui::WorkspaceGUIState& state,
891906
case MetricsDisplayStyle::Lines: {
892907
displayDeviceMetrics("Metrics",
893908
minTime, maxTime, 1024,
894-
currentStyle, metricDisplayState, metricsStore);
909+
currentStyle, metricDisplayState, metricsStore, driverInfo);
895910
} break;
896911
case MetricsDisplayStyle::Sparks: {
897912
displaySparks(state.startTime, visibleMetricsIndex, metricDisplayState, metricsStore);

0 commit comments

Comments
 (0)