Skip to content

Commit 023c4b1

Browse files
committed
benchmark: when not a TTY, just log ms
not the human-readable output, which is only for humans
1 parent 88837af commit 023c4b1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

benchmarks/timer.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ module.exports = _ => {
33
return _ => {
44
const end = process.hrtime(start)
55
const ms = Math.round(end[0]*1e6 + end[1]/1e3)/1e3
6-
const s = Math.round(end[0]*10 + end[1]/1e8)/10
7-
const ss = s <= 1 ? '' : ' (' + s + 's)'
8-
console.log('%d%s', ms, ss)
6+
if (!process.env.isTTY)
7+
console.log(ms)
8+
else {
9+
const s = Math.round(end[0]*10 + end[1]/1e8)/10
10+
const ss = s <= 1 ? '' : ' (' + s + 's)'
11+
console.log('%d%s', ms, ss)
12+
}
913
}
1014
}

0 commit comments

Comments
 (0)