fix(benchpress): only print the CV when it is meaningful

When the mean is 0, the coefficient of variation is calculated to be
NaN, which is not meaningful, so instead of printing "+-NaN%", just
don't print the CV at all.

Closes #908

Closes #1444
This commit is contained in:
Sam Rawlins
2015-04-17 18:15:22 -07:00
committed by Misko Hevery
parent 4650d25a53
commit 642e7e5c46
2 changed files with 19 additions and 3 deletions

View File

@ -96,6 +96,22 @@ export function main() {
]);
});
it('should print the coefficient of variation only when it is meaningful', () => {
createReporter({
columnWidth: 8,
metrics: { 'a': '', 'b': '' }
});
log = [];
reporter.reportSample([], [
mv(0, 0, { 'a': 3, 'b': 0 }),
mv(1, 1, { 'a': 5, 'b': 0 })
]);
expect(log).toEqual([
'======== | ========',
'4.00+-25% | 0.00'
]);
});
});
}