Giter Club home page Giter Club logo

etaprinter's Introduction

ETAPrinter

Java library that gives you the ETA and displays a progress bar when you process a batch of data.

Screenshot

The available metrics are:

  • The progression percentage (the numeric value and a cool progress bar)
  • The processing speed
  • The ETA: when will the process be finished?

Installation

Clone this github repository, launch mvn clean install and add the following maven dependency to your project:

<dependency>
  <groupId>com.vdurmont</groupId>
  <artifactId>etaprinter</artifactId>
  <version>2.0.0</version>
</dependency>

Example

You can find a working example in the examples directory.

Basic usage

Source source = // Your source of elements (your DAO for example)

// The total number of elements you will process
long total = source.size();

// Init the printer
ETAPrinter printer = ETAPrinter.init(total);

while(source.hasNext()) {
  List<Element> elements = source.getNextBatch(); // Get the next batch of elements to process

  process(elements); // That is your business logic and it may take some time

  // We update the ETA by giving the number of elements that were processed since the last update
  printer.update(elements.size());
}

Advanced usage

There are a few options that you can choose when you initialize the printer:

  • ETAPrinter.init(long total)
  • ETAPrinter.init(String elementName, long total)
  • ETAPrinter.init(long total, OutputStream stream, boolean closeStream)
  • ETAPrinter.init(String elementName, long total, OutputStream stream, boolean closeStream)

Parameters:

  • total: total number of elements that are going to be processed
  • elementName: the name of the element
    If this parameter is given, the speed will be printed with the following format: 42 [elementName]/s. Else, it will be 42/s.
  • stream: the OutputStream where the ETA is printed
    Default value is System.out.
  • closeStream: if true, the stream will be closed when the process will end (the number of processed elements will be greater or equal to the total number of elements). Default is false.

etaprinter's People

Contributors

vdurmont 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.