progress-info
determine long running progress status.
Installation
npm install --save progress-info
Usage
Asuming we want to process 100
documents and define a checkpoint size of10\
.
const ProgressInfo = ; var total = 100var checkpointSize = 10var progressInfo = total checkpointSize;var index = 0; var interval =
Yields:
checkpoint: 17:02:48 T -5.32 seconds D -90 checkpoint: 17:02:48 T -4.63 seconds D -80 checkpoint: 17:02:49 T -4.00 seconds D -70 checkpoint: 17:02:49 T -3.46 seconds D -60 checkpoint: 17:02:50 T -2.80 seconds D -50 checkpoint: 17:02:51 T -2.26 seconds D -40 checkpoint: 17:02:51 T -1.73 seconds D -30 checkpoint: 17:02:52 T -1.13 seconds D -20 checkpoint: 17:02:52 T -0.57 seconds D -10 checkpoint: 17:02:53 T -0.00 seconds D -0
API
Constructor
ProgressInfo(documentsTotal, checkpointSize)
Methods
ProgressInfo.rawTimeString(milliseconds)
returns a time in seconds as human readble string.ProgressInfo.estimatedTime(documentIndex)
returns an estimated time in seconds as human readble string.ProgressInfo.percent(documentIndex)
returns an percent value as decimal.ProgressInfo.index(documentIndex)
returns an string in form of [current document] / [total documents].ProgressInfo.docsLeft(documentIndex)
returns a counter integer of forthcoming documents.ProgressInfo.checkpoint()
resets the current time for the next measurement.ProgressInfo.time()
returns a short time string of current time.ProgressInfo.tx()
returns a short time string of past time.ProgressInfo.info(documentIndex)
returns a full information string of current progress like in the usage example above.
License
MIT © Stephan Ahlf