Coder Social home page Coder Social logo

asciiprogressbar's Introduction

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.

asciiprogressbar's People

Contributors

enewton avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.