summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorJackson Tian <shyvo1987@gmail.com>2015-11-22 17:08:45 +0800
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2016-01-06 12:10:51 -0500
commit8039ca06eb808b707313da37b9815288f50e5a24 (patch)
treecec9b9a37cd781978858b7e587b71bd10d8f5451 /benchmark
parent5a223d64e35a30262a86329d2b3e00dbd576a0e5 (diff)
downloadnode-new-8039ca06eb808b707313da37b9815288f50e5a24.tar.gz
util: faster arrayToHash
The `util.format()` is used frequently, make the method faster is better. R-URL: https://github.com/nodejs/node/pull/3964 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/util/inspect.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/benchmark/util/inspect.js b/benchmark/util/inspect.js
new file mode 100644
index 0000000000..8a59e6b48e
--- /dev/null
+++ b/benchmark/util/inspect.js
@@ -0,0 +1,15 @@
+var util = require('util');
+
+var common = require('../common.js');
+
+var bench = common.createBenchmark(main, {n: [5e6]});
+
+function main(conf) {
+ var n = conf.n | 0;
+
+ bench.start();
+ for (var i = 0; i < n; i += 1) {
+ var r = util.inspect({a: 'a', b: 'b', c: 'c', d: 'd'});
+ }
+ bench.end(n);
+}