17 report_set(false), report_set_public(false),
18 first_frame(true), fr(0), fr_avg(0), fr_count_a(0),
19 time_stamp(chc::high_resolution_clock::now()), unit(
"kHz"),
20 unit_bar(
"#"), unit_space(
"-")
25 this->report_interval = report_interval;
28 int ProgressMonitor::GetBarLength()
35 void ProgressMonitor::ClearBarField()
41 *out <<
"\r" << std::flush;
48 auto mil_secs = chc::duration_cast<float_ms>(chc::high_resolution_clock::now() - time_stamp).count();
55 Report(
fr_count, fr_avg / fr_count_a);
66 auto mil_secs = chc::duration_cast<float_ms>(chc::high_resolution_clock::now() - time_stamp).count();
73 Report(
fr_count, fr_avg / fr_count_a);
85 time_stamp = chc::high_resolution_clock::now();
88 void ProgressMonitor::Report(
size_t idx,
float print_val)
101 int bar_size = GetBarLength();
110 for (
int bar_length = 0; bar_length <= bar_size - 1; ++bar_length)
112 if (bar_length * percent_per_unit_bar < progress_percent)
122 *out << std::setprecision(2) << std::fixed << print_val << std::fixed <<
" " << unit << std::flush;
126 *out <<
" " << std::endl
133 std::cerr <<
"EXCEPTION: frame index (" << e <<
") went out of bounds (fr_total = " <<
fr_total <<
")." << std::endl
#define CHARACTER_WIDTH_PERCENTAGE
ProgressMonitor & operator+=(int step)
std::atomic< bool > report_set
std::atomic< size_t > fr_count_i
ProgressMonitor(size_t fr_total, bool b_bar=true, float report_interval=250.0, std::ostream &out=std::cerr)
ProgressMonitor & operator++()
std::atomic< size_t > fr_count
std::atomic< bool > report_set_public