From 22aa3d48997f1fc31e9c9cc08ec76a5436c93fe3 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Mon, 17 Apr 2017 04:01:12 +0300 Subject: benchmark: reduce string concatenations PR-URL: https://github.com/nodejs/node/pull/12455 Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell --- benchmark/_benchmark_progress.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'benchmark/_benchmark_progress.js') 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) { -- cgit v1.2.3