estatusbar: Statusbar that estimates the remaining time based on the...

Description Usage Format Initialization Adding new entries Displaying the status bar Examples

Description

This is an R port of a Fortran module that was used in the astrophysical codes SPEV and MRGENESIS.

Usage

1

Format

An object of class R6ClassGenerator of length 24.

Initialization

An R6 object is initalized sing estatusbar$new() with a no arguments. It should be called by the user when the task starts.

Adding new entries

As the task progresses, the user can call the function add to register the fraction of the task that has been completed. The routine add has only one argument, the fraction (between 0 and 1) that is complete at current time.

Displaying the status bar

At any point the user can call the display function to draw the status bar in terminal. This function accepts the following arguments: width = 40, text = NULL, perc = TRUE, eta = TRUE, digits=0

width

The width of the progress bar. The default values is 40 characters

text

A custom text string that can be shown next to the progress bar. By default no text is displayed.

perc

Percentage display flag, by default set to TRUE. This controls whether the percentage of progress should be printed.

eta

Estimated completion time display flag, by default set to TRUE. This controls whether the ETA should be printed.

digits

Total number of digits to be used when printing seconds, by default set to 0. This allows the user to show fractions of a second.

Examples

1
2
3
4
5
6
7
8
What follows is the typical usage case. The status bar is registered, and then 20 entries are added. Before each add the system sleeps for a random time interval (between 0 and 2 seconds). Afterward an entry is registered and the display is updated.

est <- estatusbar$new()
for (i in 1:20) {
   Sys.sleep(2 * runif(1))
   est$add(i / 20)
   est$display()
}

petarmimica/estatusbar documentation built on May 29, 2019, 7:36 a.m.