-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(956) human readable estimates (#956) #1176
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I have some small remarks, but they are non-blocking in my opinion :)
const minutes = Math.floor((timeLeft / 60) - (hours * 60)); | ||
const seconds = Math.floor(timeLeft - (hours * 3600) - (minutes * 60)); | ||
|
||
let output = (hours !== 0) ? `${hours}h, ` : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nicer to check for a positive number. If any of our inputs is negative, we will probably end up with a negative timeleft.
@@ -22,18 +22,21 @@ export default class ProgressBarReporter extends ProgressKeeper { | |||
public onMutantTested(result: MutantResult): void { | |||
const ticksBefore = this.progress.tested; | |||
super.onMutantTested(result); | |||
|
|||
const progressBarContent = Object.assign(this.progress, { etc: this.getEtc() }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also use the spread operator here: const progressBarContent = { ...this.progress, etc: this.getEtc() };
Cool PR. I would like to review before merging. 👍 |
I refactored a bit of the code to process Simons feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this approach. It also aligns the ProgressAppendOnlyReporter
.
I've got some small remarks. One show stopper for me is the leaving out of minutes when there are hours.
if (isFinite(timeLeft)) { | ||
const hours = Math.floor(timeLeft / 3600); | ||
const minutes = Math.floor((timeLeft / 60) - (hours * 60)); | ||
const seconds = Math.floor(timeLeft - (hours * 3600) - (minutes * 60)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplification suggestion:
const hours = Math.floor(totalSecondsLeft / 3600);
const minutes = Math.floor(totalSecondsLeft / 60 % 60);
const seconds = Math.floor(totalSecondsLeft % 60);
@@ -24,5 +26,23 @@ abstract class ProgressKeeper implements Reporter { | |||
this.progress.survived++; | |||
} | |||
} | |||
|
|||
protected getEtc() { | |||
const timeLeft = Math.floor(this.timer.elapsedSeconds() / this.progress.tested * (this.progress.total - this.progress.tested)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should now be renamed to "totalSecondsLeft", as everything here has to do with "time left"
const seconds = Math.floor(timeLeft - (hours * 3600) - (minutes * 60)); | ||
|
||
let output = (hours > 0) ? `${hours}h, ` : ''; | ||
output += (minutes > 0) ? `${minutes}m, ` : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When hours is greater than 0, but minutes is 0 it means that minutes is left out. Though technically correct, i think it would be clearer if minutes is displayed. For example: 1h, 0m, 20s
instead of 1h, 20s
.
Suggestion:
if (hours > 0) {
return `${hours}h, ${minutes}m, ${seconds}s`;
} else if(minutes > 0) {
return `${minutes}m, ${seconds}s`;
} else {
return `${seconds}s`
}
expect(progressBar.tick).to.have.been.calledWithMatch({ etc: '10s' }); | ||
}); | ||
|
||
it('should show to an estimate of "1m, 40s" in the progressBar after hundred seconds and 1 mutants tested', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous remark about leaving out minutes.
checks whether minutes and seconds is shown when there is exactly one hour left
@nicojs, should be good to go now. |
Awesome 👍 |
Adds human readable estimates to the progressbar during stryker testing.
resolves #956