Molecular Dynamics Simulation  1.0
FormatTime.cpp
Go to the documentation of this file.
1 #include "FormatTime.h"
2 
3 #include "io/logger/Logger.h"
4 
5 std::string format_seconds_eta(int total_seconds) {
6  if (total_seconds < 0) {
7  return "N/A";
8  }
9 
10  int hours = total_seconds / 3600;
11  int minutes = (total_seconds % 3600) / 60;
12  int seconds = total_seconds % 60;
13 
14  return fmt::format("{:02d}:{:02d}:{:02d}", hours, minutes, seconds);
15 }
16 
17 std::string format_mup_s(double mup_s) {
18  if (mup_s < 0) {
19  return "N/A";
20  }
21 
22  std::string suffix = "";
23  if (mup_s > 1000000) {
24  mup_s /= 1000000;
25  suffix = "M";
26  } else if (mup_s > 1000) {
27  mup_s /= 1000;
28  suffix = "k";
29  }
30 
31  return fmt::format("{:.2f}{}", mup_s, suffix);
32 }
33 
34 std::string format_seconds_total(double total_seconds) {
35  if (total_seconds < 0) {
36  return "N/A";
37  }
38 
39  int hours = static_cast<int>(total_seconds) / 3600;
40  int minutes = (static_cast<int>(total_seconds) % 3600) / 60;
41  int seconds = static_cast<int>(total_seconds) % 60;
42  int millis = static_cast<int>(total_seconds * 1000) % 1000;
43 
44  return fmt::format("{}h {}m {}s {}ms", hours, minutes, seconds, millis);
45 }
std::string format_seconds_total(double total_seconds)
Formats the given seconds into a string of the form "HHh MMm SSs MMMms".
Definition: FormatTime.cpp:34
std::string format_seconds_eta(int total_seconds)
Formats the given seconds into a string of the form "HH:MM:SS".
Definition: FormatTime.cpp:5
std::string format_mup_s(double mup_s)
Formats the given mup/s into a string.
Definition: FormatTime.cpp:17