vSMC
vSMC: Scalable Monte Carlo
|
Display a progress bar while algorithm proceed. More...
#include <vsmc/utility/progress.hpp>
Public Types | |
typedef ThreadType | thread_type |
Public Member Functions | |
Progress (std::ostream &os=std::cout) | |
Construct a Progress with an output stream. More... | |
void | increment (std::size_t step=1) |
Increment the iteration count. More... | |
void | start (std::size_t total, const std::string &msg=std::string(), std::size_t length=0, bool show_iter=false, double interval=0.1) |
Start to print the progress. More... | |
void | stop (bool finished=false) |
Stop to print the progress. More... | |
Display a progress bar while algorithm proceed.
ThreadType | Any type that (partially) follows C++11 std::thread interface. In particular, the following calls shal be supported, void (task *) (void *); // A function pointer
void *context; // A void pointer
ThreadType *thread_ptr_ = new ThreadType(task, context);
thread_ptr_->joinable();
thread_ptr_->join();
delete thread_ptr_;
|
ThisThread | This shall be a class that provides a sleep static member function that allows the calling thread to sleep for a specified time in seconds. A simple implementation using C++11 sleep_for is as the following, struct ThisThread
{
static void sleep (double s)
{
// Make the interval acurate to milliseconds
double ms = std::max(1.0, std::floor(s * 1000));
std::this_thread::sleep_for(std::chrono::milliseconds(
static_cast<std::chrono::milliseconds::rep>(ms)));
}
};
std to boost . |
Definition at line 100 of file progress.hpp.
typedef ThreadType vsmc::Progress< ThreadType, ThisThread >::thread_type |
Definition at line 104 of file progress.hpp.
|
inline |
Construct a Progress with an output stream.
Definition at line 107 of file progress.hpp.
|
inline |
Increment the iteration count.
Definition at line 158 of file progress.hpp.
|
inline |
Start to print the progress.
total | Total amount of work represented by an integer, for example file size or SMC algorithm total number of iterations |
msg | A (short) discreptive message |
length | The length of the progress bar between brackets. If it is zero, then no bar is displayed at all |
show_iter | Shall the iteration count be displayed. |
interval | The sleep interval in seconds |
Definition at line 122 of file progress.hpp.
|
inline |
Stop to print the progress.
finished | If true, then it is assumed that all work has been finished, and at the end the progress will be shown as 100% and total/total , where total is the first parameter of start . Otherwise, whatever progress has been made will be shown. |
Definition at line 147 of file progress.hpp.