11 init(total, barwidth);
19 void init(
int total,
int barwidth)
40 std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
43 if (std::chrono::duration_cast<std::chrono::milliseconds>(now -
last_print_time_).count() > 33
46 double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now -
start_time_).count() / 1000.0;
52 std::cout << *(
bars_.end() - 1);
53 else if (
i == floor(pos))
54 std::cout <<
bars_[round((pos - floor(pos)) * (
bars_.size() - 1))];
59 double it_s = completed / elapsed;
60 std::string left_stamp =
ms_to_stamp(((total_ - completed) / it_s) * 1000);
61 std::string elapsed_stamp =
ms_to_stamp(elapsed * 1000.0);
62 printf(
"[%s<%s, %.2fit/s] ", elapsed_stamp.c_str(), left_stamp.c_str(), it_s);
78 int sec = ((ms - millis) % (60 * 1000)) / 1000;
79 int min = ((ms - (millis + sec * 1000)) % (60 * 60 * 1000)) / (60 * 1000);
80 int hour = ((ms - (millis + (sec + min * 60) * 1000)) % (24 * 60 * 60 * 1000)) / (60 * 60 * 1000);
81 int day = ((ms - (millis + (sec + (min + hour * 60) * 60) * 1000)) / (24 * 60 * 60 * 1000)) / (24 * 60 * 60 * 1000);
85 n =
sprintf(buf,
"%d:%d:%02d:%02d:%03d", day, hour, min, sec, millis);
87 n =
sprintf(buf,
"%d:%02d:%02d:%03d", hour, min, sec, millis);
89 n =
sprintf(buf,
"%d:%02d:%03d", min, sec, millis);
91 n =
sprintf(buf,
"%d:%03d", sec, millis);
104 std::vector<const char*>
bars_ = {
" ",
"▏",
"▎",
"▍",
"▋",
"▋",
"▊",
"▉",
"▉",
"█"};
std::chrono::system_clock::time_point last_print_time_
void init(int total, int barwidth)
void set_theme_braille_spin()
void print(int completed)
std::vector< const char * > bars_
ProgressBar(int total, int barwidth)
std::chrono::system_clock::time_point start_time_
std::string ms_to_stamp(int ms)