bench-chain
Version:
benchmark recording - averages & graphs.
40 lines (36 loc) • 988 B
JavaScript
/**
* @since 0.0.2
* @see Record.avgs
* @return {Record} @chainable
*/
echoAvgGraphInOne() {
const avgs = this.avgs()
const nums = Object.keys(avgs).map(name => Number(avgs[name]))
const max = flowmax(...nums)
const min = flowmin(...nums)
const div = getDiv(max) * 10
const points = Object.keys(avgs).map((name, i) => {
return [i, Math.floor(avgs[name] / div)]
})
if (this.max < max) this.max = max
if (this.min < min) this.min = min
// , {max, min, nums, points}
log
.blue('averages of: ')
.data(Object.keys(avgs))
.echo(this.shouldEcho || true)
log
.barStyles({
color: 'blue',
// width: 150,
maxY: Math.floor(max / div),
minY: Math.floor(min / div),
// height: 100,
// yFractions: 0,
// xFractions: 0,
caption: 'averages of all (in one):',
})
.bar(points)
.echo(this.shouldEcho || true)
return this
}