Skip to content

Commit

Permalink
Add total time logging at the end of the simulation (#1908)
Browse files Browse the repository at this point in the history
close  #1907

---------

Co-authored-by: Florian Omnès <[email protected]>
  • Loading branch information
payetvin and flomnes authored Feb 1, 2024
1 parent c57fdfe commit 6555fcb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/solver/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,18 @@ void Application::writeComment(Data::Study& study)
}
}

static void logTotalTime(unsigned duration)
{
std::chrono::milliseconds d(duration);
auto hours = std::chrono::duration_cast<std::chrono::hours>(d);
d -= hours;
auto minutes = std::chrono::duration_cast<std::chrono::minutes>(d);
d -= minutes;
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(d);

logs.info().appendFormat("Total simulation time: %02luh%02lum%02lus", hours.count(), minutes.count(), seconds.count());
}

void Application::writeExectutionInfo()
{
if (!pStudy)
Expand All @@ -437,6 +449,8 @@ void Application::writeExectutionInfo()
pTotalTimer.stop();
pDurationCollector.addDuration("total", pTotalTimer.get_duration());

logTotalTime(pTotalTimer.get_duration());

// If no writer is available, we can't write
if (!resultWriter)
return;
Expand Down

0 comments on commit 6555fcb

Please sign in to comment.