From 0e280f7474097a72894d4a4bcf9a18e58c0aece9 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Thu, 3 May 2018 10:13:03 +0200
Subject: [PATCH] Better detailed timers

Actions are now shown in order also when they are more than 10.
Perhaps should be cleaned up a bit, but it works.
---
 src/core/PlumedMain.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/core/PlumedMain.cpp b/src/core/PlumedMain.cpp
index 65191791f..4c4f8e026 100644
--- a/src/core/PlumedMain.cpp
+++ b/src/core/PlumedMain.cpp
@@ -676,6 +676,10 @@ void PlumedMain::justCalculate() {
       if(detailedTimers) {
         std::string actionNumberLabel;
         Tools::convert(iaction,actionNumberLabel);
+        const unsigned m=actionSet.size();
+        unsigned k=0; unsigned n=1; while(n<m) { n*=10; k++; }
+        const int pad=k-actionNumberLabel.length();
+        for(int i=0; i<pad; i++) actionNumberLabel=" "+actionNumberLabel;
         sw=stopwatch.startStop("4A "+actionNumberLabel+" "+p->getLabel());
       }
       ActionWithValue*av=dynamic_cast<ActionWithValue*>(p);
@@ -722,6 +726,10 @@ void PlumedMain::backwardPropagate() {
       if(detailedTimers) {
         std::string actionNumberLabel;
         Tools::convert(iaction,actionNumberLabel);
+        const unsigned m=actionSet.size();
+        unsigned k=0; unsigned n=1; while(n<m) { n*=10; k++; }
+        const int pad=k-actionNumberLabel.length();
+        for(int i=0; i<pad; i++) actionNumberLabel=" "+actionNumberLabel;
         sw=stopwatch.startStop("5A "+actionNumberLabel+" "+p->getLabel());
       }
 
-- 
GitLab