27 }
else if (unit ==
"s") {
29 }
else if (unit ==
"min") {
32 return 1000 * 60 * 60;
39 : total_steps_(total_steps), start_time_(
Timing::Timestamp()) {}
52 if (!isatty(fileno(stdout))) {
53 std::cout <<
"<ProgressBar::PrintProgressBar> omits output because you "
59 out <<
"ET = Elapsed Time; TR = Time Remaining" << std::endl;
77 assert(fraction_computed <= 1);
78 real_t remaining_time = elapsed_time / fraction_computed - elapsed_time;
83 size_t n_steps_computed = std::floor(fraction_computed / 0.02);
86 std::string terminal_output =
"";
87 terminal_output.append(
"[")
88 .append(std::string(n_steps_computed,
'#'))
89 .append(std::string(50 - n_steps_computed,
' '))
95 terminal_output.append(
"( ET: ")
96 .append(std::to_string(elapsed_time))
98 .append(std::to_string(remaining_time))
102 terminal_output.append(
"\r");
110 terminal_output.append(
115 out << terminal_output;
125 if (time_unit ==
"ms" || time_unit ==
"s" || time_unit ==
"min" ||
131 "Time unit not supported. Use ms, s, min, h instead. ",
132 "Falling back to [s].");
static void Warning(const std::string &location, const Args &... parts)
Prints warning message.
This class implements a progress bar that can be used to track the progress of a simulation.
real_t time_conversion_factor_
Variable for conversion of time units (e.g. 1000 for ms to s).
void Step(uint64_t steps=1)
Inceases the counter executed_steps_ by steps.
void SetTimeUnit(const std::string &time_unit)
void PrintProgressBar(std::ostream &out=std::cout)
Prints the progress bar.
std::string time_unit_
Time unit string for elapsed and remaining time.
int64_t start_time_
Timestamp when to when the progress bar was initialized.
uint64_t total_steps_
Total number of steps to be executed.
uint64_t executed_steps_
Number of steps that have already been executed.
static int64_t Timestamp()
real_t TimeConversionFactor(const std::string &unit)