ASCII Progress Bar & ETA (Fully Configurable)
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:
-
It is designed to be simple to use initially, and yet be very powerful and configurable.
-
It can be distributed via a single file
ProgressBar.m
which also contains a duplicate of theLICENSE
.
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)
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
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
.
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.
- 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
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
tests
Version | Published | Release Notes | |
---|---|---|---|
1.0.0 |