Skip to content

ligumas/cpprogress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cpprogress

progress bars and spinners for C++17 terminal apps

CI C++17 header-only license

drop progress.hpp into your project.

#include "progress.hpp"

// basic bar
progress::Bar bar(total, "training");
for (auto& batch : batches) {
    train(batch);
    bar.update();
}
bar.finish();

output:

training [===================>        ]  72% 1243.5/s eta 00:03

spinner for when you don't know the total:

progress::Spinner s("loading dataset...");
s.start();
load_data();
s.stop("done");

multiple bars at once:

progress::MultiBar mb;
auto& download = mb.add(1000, "download");
auto& extract  = mb.add(500,  "extract");
mb.start();

std::thread t1([&]{ for (int i=0; i<1000; i++) { do_work(); download.update(); } });
std::thread t2([&]{ for (int i=0; i<500;  i++) { do_work(); extract.update();  } });
t1.join(); t2.join();

mb.stop();

output:

download [===================>        ]  72% 1243.5/s eta 00:03
extract  [===========>                ]  44%  980.1/s eta 00:02

colored bars:

#include "progress.hpp"

progress::Bar bar(total, "training");
bar.bar_color = progress::color::green;   // green fill
bar.update(50);
bar.finish();

// available: color::green, yellow, red, blue, cyan, magenta

Bar options:

bar.width = 40;        // bar width in chars
bar.show_eta = true;
bar.show_rate = true;
bar.bar_color = progress::color::cyan;

License: MIT

About

header-only C++17 progress bars and spinners for terminal apps

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages