summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2017-12-16 01:33:56 -0200
committerRuben Bridgewater <ruben@bridgewater.de>2017-12-20 01:33:50 -0300
commit0eab49523d75235cbd14047da5b74467596ae590 (patch)
tree04e3f1f38d383b8f1a77433a5f9e416c5582e63b /lib
parent1d6b729cea909769ac0bcb3aa68f5fe567c4ffb7 (diff)
downloadandroid-node-v8-0eab49523d75235cbd14047da5b74467596ae590.tar.gz
android-node-v8-0eab49523d75235cbd14047da5b74467596ae590.tar.bz2
android-node-v8-0eab49523d75235cbd14047da5b74467596ae590.zip
benchmark: refactor console benchmark
Fix and refactor the console benchmark. It did not test console so it got renamed and mainly tests the different ways of passing arguments through. PR-URL: https://github.com/nodejs/node/pull/17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/console.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/console.js b/lib/console.js
index 654b5b8280..ae268d8f84 100644
--- a/lib/console.js
+++ b/lib/console.js
@@ -132,12 +132,12 @@ function write(ignoreErrors, stream, string, errorhandler, groupIndent) {
}
-// As of v8 5.0.71.32, the combination of rest param, template string
-// and .apply(null, args) benchmarks consistently faster than using
-// the spread operator when calling util.format.
Console.prototype.log = function log(...args) {
write(this._ignoreErrors,
this._stdout,
+ // The performance of .apply and the spread operator seems on par in V8
+ // 6.3 but the spread operator, unlike .apply(), pushes the elements
+ // onto the stack. That is, it makes stack overflows more likely.
util.format.apply(null, args),
this._stdoutErrorHandler,
this[kGroupIndent]);