ENH: make format of ExecutionTime = ... output configurable (issue #788)

- controlled by the the 'printExecutionFormat' InfoSwitch in
  etc/controlDict

      // Style for "ExecutionTime = " output
      // - 0 = seconds (with trailing 's')
      // - 1 = day-hh:mm:ss

   ExecutionTime = 112135.2 s  ClockTime = 113017 s

   ExecutionTime = 1-07:08:55.20  ClockTime = 1-07:23:37

- Callable via the new Time::printExecutionTime() method,
  which also helps to reduce clutter in the applications.
  Eg,

     runTime.printExecutionTime(Info);

  vs

     Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
         << "  ClockTime = " << runTime.elapsedClockTime() << " s"
         << nl << endl;

--

ENH: return elapsedClockTime() and clockTimeIncrement as double

- previously returned as time_t, which is less portable.
This commit is contained in:
Mark Olesen
2018-04-27 15:00:34 +02:00
parent 0743b61a3c
commit dd8341f659
125 changed files with 311 additions and 388 deletions

View File

@ -30,6 +30,7 @@ License
#include "profiling.H"
#include "demandDrivenData.H"
#include "IOdictionary.H"
#include "registerSwitch.H"
#include <sstream>
@ -77,6 +78,19 @@ const int Foam::Time::maxPrecision_(3 - log10(SMALL));
Foam::word Foam::Time::controlDictName("controlDict");
int Foam::Time::printExecutionFormat_
(
Foam::debug::infoSwitch("printExecutionFormat", 0)
);
registerInfoSwitch
(
"printExecutionFormat",
int,
Foam::Time::printExecutionFormat_
);
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -1161,7 +1175,7 @@ Foam::Time& Foam::Time::operator++()
{
const label writeIndex = label
(
returnReduce(label(elapsedClockTime()), maxOp<label>())
returnReduce(elapsedClockTime(), maxOp<double>())
/ writeInterval_
);
if (writeIndex > writeTimeIndex_)