You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
426 B
20 lines
426 B
5 months ago
|
#pragma once
|
||
|
|
||
|
#include <cstdio>
|
||
|
|
||
|
#define PBSTR "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
|
||
|
#define PBWIDTH 60
|
||
|
|
||
|
template <typename Real>
|
||
|
void print_progress_bar(Real percentage, bool verbose = true)
|
||
|
{
|
||
|
if (verbose)
|
||
|
{
|
||
|
int val = (int)(percentage * 100);
|
||
|
int lpad = (int)(percentage * PBWIDTH);
|
||
|
int rpad = PBWIDTH - lpad;
|
||
|
printf("\r%3d%% [%.*s%*s]", val, lpad, PBSTR, rpad, "");
|
||
|
fflush(stdout);
|
||
|
}
|
||
|
}
|