ASCII Progress Bar & ETA (Fully Configurable)

Version 1.0.0 (8.88 KB) by Erik Newton
Simple to use, and yet powerful, ASCII progress bar for MATLAB console.
1 Download
Updated 2 Jun 2024

ASCII Progress Bar

Introduction

This class creates a progress message in the MATLAB console, useful when processing long loops. It can display an ASCII progress bar as well as estimate the remaining time by profiling the initial loops.

There are many other MATLAB progress bars out there, but here are a few reasons why this one is worth considering:

  1. It is designed to be simple to use initially, and yet be very powerful and configurable.

  2. It can be distributed via a single file ProgressBar.m which also contains a duplicate of the LICENSE.

You need to construct an instance of ProgressBar telling it how many iterations the loop will be. If running nested loops, then initialise it with the product of all the loop sizes (See exampleBasic.m)

Example

In the example below, we have a loop, with a pause to simulate some work being done. In a real application, this is where you would be running your slow algorithm, loading a file etc.

numSteps = 100;

% Need to tell ProgressBar how many steps there will be
pb = ProgressBar(numSteps);

for lp = 1:numSteps

    % Do some work
    pause(0.1);

    % Display the progress bar
    pb.disp("Progress: {bar} Time remaining: {timeRemaining}");
end

The above code wiil display the following animated display in the console:

Progress: [########............] Time remaining: 5.4 seconds

Options

The following placeholder strings enclosed in {braces} can be used in the disp format string:

Field Placeholder Description Associated Example
{bar} ASCII graphical progress bar exampleBasic.m
{eta} 'Estimated Time of Arrival'. Estimate of absolute date/time of completion exampleEta.m
{timeRemaining} Estimated time remaining in sensible units. (seconds/minutes/hours) exampleBasic.m
{timeElapsed} Elapsed time in sensible units. (seconds/minutes/hours) exampleEta.m
{step} Current iteration number. exampleSteps.m
{steps} Total number of iterations to complete exampleSteps.m

In addition to defining your own format string, you can also set a number of other properties via the ProgressBar constructor. See exampleOptions.m.

Tests

The project is fully unit tested. To run the tests on your version of MATLAB, simply run the script runTests.m. Please report any failures, mentioning the MATLAB version and ProgressBar version you used.

Limiations

  1. Not looked at parfor support yet.

Cite As

Erik Newton (2024). ASCII Progress Bar & ETA (Fully Configurable) (https://github.com/enewton/AsciiProgressBar/releases/tag/v1.0.0), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2021b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.