RcppThread::ProgressPrinter class

Abstract class for printing progress.

This class contains most of the logic for tracking progress in a parallel loop. Child classes must define a method void printProgress() that is called whenever an update is required.

Derived classes

class ProgressBar
A progress bar showing progress in percent.
class ProgressCounter
A counter showing progress in percent.

Constructors, destructors, conversion operators

ProgressPrinter(size_t numIt, size_t printEvery = 1)

Public functions

void printProgress() pure virtual
prints progress whenever an update is necessary.
auto operator++() -> size_t
pre-increment operator
auto operator++(int) -> size_t
post-increment operator

Protected functions

auto needsPrint() -> bool
checks whether it's time for an update.
auto remainingSecs() -> size_t
estimates the remaining time in seconds.
auto progressString() -> std::string
prints either remaining time or that the computation is done.
auto formatTime(size_t secs) -> std::string

Protected variables

std::atomic_size_t it_
iteration counter
std::atomic_size_t numUpdates_
counter for the number of updates
std::atomic_bool isDone_
flag indicating end of iterations
size_t numIt_
total number of iterations
size_t printEvery_
std::chrono::time_point<std::chrono::steady_clock> startTime_
time at start

Function documentation

RcppThread::ProgressPrinter::ProgressPrinter(size_t numIt, size_t printEvery = 1)

Parameters
numIt total number of iterations.
printEvery how regularly to print updates (in seconds).

Constructor for abstract class ProgressPrinter.

std::string RcppThread::ProgressPrinter::formatTime(size_t secs) protected

Parameters
secs in seconds.

formats time into {days}d{hours}h{minutes}m{seconds}s.

Variable documentation

size_t RcppThread::ProgressPrinter::printEvery_ protected

update frequency