BioDynaMo  v1.05.120-25dc9790
Public Member Functions | Private Attributes | List of all members
bdm::ProgressBar Class Reference

This class implements a progress bar that can be used to track the progress of a simulation. More...

#include <progress_bar.h>

Collaboration diagram for bdm::ProgressBar:
[legend]

Public Member Functions

 ProgressBar ()
 
 ProgressBar (int total_steps)
 
void Step (uint64_t steps=1)
 Inceases the counter executed_steps_ by steps. More...
 
void PrintProgressBar (std::ostream &out=std::cout)
 Prints the progress bar. More...
 
void SetTimeUnit (const std::string &time_unit)
 

Private Attributes

std::string time_unit_ = "s"
 Time unit string for elapsed and remaining time. More...
 
uint64_t total_steps_ = 0
 Total number of steps to be executed. More...
 
uint64_t executed_steps_ = 0
 Number of steps that have already been executed. More...
 
int64_t start_time_ = 0
 Timestamp when to when the progress bar was initialized. More...
 
size_t n_terminal_chars_ = 0
 
real_t time_conversion_factor_ = 1000
 Variable for conversion of time units (e.g. 1000 for ms to s). More...
 
bool first_iter_ = true
 
bool write_to_file_ = false
 

Detailed Description

This class implements a progress bar that can be used to track the progress of a simulation.

The progress bar is printed to the terminal and looks like this: 100% [====================] 1000/1000 0.0s

The progress bar is updated every time the function Step is called in the scheduler.

The progress bar is not visible if the simulation output is written to a file.

Relevant parameters:

Definition at line 40 of file progress_bar.h.

Constructor & Destructor Documentation

◆ ProgressBar() [1/2]

bdm::ProgressBar::ProgressBar ( )

Definition at line 36 of file progress_bar.cc.

◆ ProgressBar() [2/2]

bdm::ProgressBar::ProgressBar ( int  total_steps)
explicit

Definition at line 38 of file progress_bar.cc.

Member Function Documentation

◆ PrintProgressBar()

void bdm::ProgressBar::PrintProgressBar ( std::ostream &  out = std::cout)

Prints the progress bar.

Definition at line 43 of file progress_bar.cc.

◆ SetTimeUnit()

void bdm::ProgressBar::SetTimeUnit ( const std::string &  time_unit)

Set the time unit (and the conversion factor) for elapsed and remaining time.

Definition at line 123 of file progress_bar.cc.

◆ Step()

void bdm::ProgressBar::Step ( uint64_t  steps = 1)

Inceases the counter executed_steps_ by steps.

Definition at line 41 of file progress_bar.cc.

Member Data Documentation

◆ executed_steps_

uint64_t bdm::ProgressBar::executed_steps_ = 0
private

Number of steps that have already been executed.

Definition at line 47 of file progress_bar.h.

◆ first_iter_

bool bdm::ProgressBar::first_iter_ = true
private

Boolean variable to print certain information only once in the first iteration.

Definition at line 57 of file progress_bar.h.

◆ n_terminal_chars_

size_t bdm::ProgressBar::n_terminal_chars_ = 0
private

Keep track of space that is needed for printing elapsed and remaining time for nicer output.

Definition at line 52 of file progress_bar.h.

◆ start_time_

int64_t bdm::ProgressBar::start_time_ = 0
private

Timestamp when to when the progress bar was initialized.

Definition at line 49 of file progress_bar.h.

◆ time_conversion_factor_

real_t bdm::ProgressBar::time_conversion_factor_ = 1000
private

Variable for conversion of time units (e.g. 1000 for ms to s).

Definition at line 54 of file progress_bar.h.

◆ time_unit_

std::string bdm::ProgressBar::time_unit_ = "s"
private

Time unit string for elapsed and remaining time.

Definition at line 43 of file progress_bar.h.

◆ total_steps_

uint64_t bdm::ProgressBar::total_steps_ = 0
private

Total number of steps to be executed.

Definition at line 45 of file progress_bar.h.

◆ write_to_file_

bool bdm::ProgressBar::write_to_file_ = false
private

Variable to detect if we write to a file or not. ProgressBar is not visible if we write to file.

Definition at line 60 of file progress_bar.h.


The documentation for this class was generated from the following files: