diff options
author | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2017-04-17 04:01:12 +0300 |
---|---|---|
committer | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2017-04-20 04:46:37 +0300 |
commit | 22aa3d48997f1fc31e9c9cc08ec76a5436c93fe3 (patch) | |
tree | 255361bcfb0611af60f6c7c101c886687d0ce047 /benchmark/_benchmark_progress.js | |
parent | bbbb1f60780d9b8ef812769e215be830c4d968b8 (diff) | |
download | android-node-v8-22aa3d48997f1fc31e9c9cc08ec76a5436c93fe3.tar.gz android-node-v8-22aa3d48997f1fc31e9c9cc08ec76a5436c93fe3.tar.bz2 android-node-v8-22aa3d48997f1fc31e9c9cc08ec76a5436c93fe3.zip |
benchmark: reduce string concatenations
PR-URL: https://github.com/nodejs/node/pull/12455
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark/_benchmark_progress.js')
-rw-r--r-- | benchmark/_benchmark_progress.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/benchmark/_benchmark_progress.js b/benchmark/_benchmark_progress.js index 4afae2f77d..5e2ae4ab11 100644 --- a/benchmark/_benchmark_progress.js +++ b/benchmark/_benchmark_progress.js @@ -3,12 +3,13 @@ const readline = require('readline'); function pad(input, minLength, fill) { - var result = input + ''; - return fill.repeat(Math.max(0, minLength - result.length)) + result; + var result = String(input); + var padding = fill.repeat(Math.max(0, minLength - result.length)); + return `${padding}${result}`; } function fraction(numerator, denominator) { - const fdenominator = denominator + ''; + const fdenominator = String(denominator); const fnumerator = pad(numerator, fdenominator.length, ' '); return `${fnumerator}/${fdenominator}`; } @@ -100,11 +101,12 @@ class BenchmarkProgress { const percent = pad(Math.floor(completedRate * 100), 3, ' '); const caption = finished ? 'Done\n' : this.currentFile; - return `[${getTime(diff)}|% ${percent}` + - `| ${fraction(completedFiles, scheduledFiles)} files ` + - `| ${fraction(completedRunsForFile, runsPerFile)} runs ` + - `| ${fraction(completedConfig, scheduledConfig)} configs]` + - `: ${caption} `; + return `[${getTime(diff)}|% ${ + percent}| ${ + fraction(completedFiles, scheduledFiles)} files | ${ + fraction(completedRunsForFile, runsPerFile)} runs | ${ + fraction(completedConfig, scheduledConfig)} configs]: ${ + caption} `; } updateProgress(finished) { |