-
Notifications
You must be signed in to change notification settings - Fork 34
option to calculate and display an ETA #22
Comments
@jokeyrhyme So this was kind of a pain with gauge@1, but with the just released gauge@2 it's pretty easy... it'd be something like var themes = require('gauge/themes')
var Gauge = require('gauge')
// Add the ability to include eta to all existing and future themes
themes.addToAllThemes({
eta: function (values, theme, width) {
// compute the eta here, in the example we just hard code it
// values.completed has the percent completion in it.
return 'eta 3m30s'
}
})
// add a new template that includes the eta
var etaTemplate = [
{type: 'progressbar', length: 20},
{type: 'eta', length: 9},
{type: 'activityIndicator', kerning: 1, length: 1},
{type: 'section', kerning: 1},
{type: 'subsection', kerning: 1}
]
var gauge = new Gauge(process.stderr, {template: etaTemplate}) I would be all for adding an |
@iarna thanks. I see if I can play with this soon. :) |
@jokeyrhyme I updated the example to use the updated theme mixin support. |
Thanks =) I've fiddled a bit with adding ETA support and right now I'm seeing a lot more jitter in the estimates than I'd like, dejittering it requires some place for template functions to store state, which will require a bit of architectural fiddling, but it's on my mind. |
Yeah, I've actually started wondering about a React renderer for the console. Not using blessed or ncurses, just something that renders (or re-renders) one line at a time for typical non-interactive console output. Then we could really treat everything on that line as a component, which might make things like progress bars and colours easier to manage. Hmmmm..... |
My wip for this is over here: |
It has It also has a pretty nice implementation of the The jitter was easy enough to cleanup by just not updating the eta every tick (I, arbitrarily, chose once a second, and that feels a lot better). themes.addToAllThemes({
'eta': function (values, theme, width) {
var eta = getEta(this)
var now = process.hrtime()
var sinceLast = elapsed(now, eta.last)
if (sinceLast >= 1 || !eta.remaining || eta.remaining < 1) {
var tillNow = elapsed(eta.last, eta.created)
var remaining = (tillNow / values.completed) - tillNow
eta.last = now
eta.remaining = remaining
}
return formatNumber(eta.remaining)
},
'elapsed': function (values, theme, width) {
var eta = getEta(this)
return formatNumber(elapsed(process.hrtime(), eta.created))
}
}) Originally I was using |
For a CLI project I'm currently engaged in, I looked closely at both gauge and https://github.com/tj/node-progress . I ended up opting for gauge, primarily because my project discovers more work to do as it progresses, which gauge handles perfectly.
However, I would like to eventually display an ETA to my users, especially as the workload stabilises fairly early within the process. Just not early enough to use progress instead.
Is this something that you think is within the scope of this project?
Or should we have some sort of extension mechanism first, and develop ETAs as a third-party extension?
The text was updated successfully, but these errors were encountered: