summaryrefslogtreecommitdiff
path: root/benchmark/tls
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2016-06-08 15:47:18 -0700
committerJames M Snell <jasnell@gmail.com>2016-06-21 10:53:25 -0700
commitf3d5efa3ee4432121f6e2a1866f1179b09056594 (patch)
tree87e18ee9956c8c30d53b06bcfea4fcb1409f4367 /benchmark/tls
parent6be73feaeb31dbcc1547da648341c0b6f0d2d2bb (diff)
downloadandroid-node-v8-f3d5efa3ee4432121f6e2a1866f1179b09056594.tar.gz
android-node-v8-f3d5efa3ee4432121f6e2a1866f1179b09056594.tar.bz2
android-node-v8-f3d5efa3ee4432121f6e2a1866f1179b09056594.zip
tls: avoid calling Buffer.byteLength multiple times
There's no reason to be calling Buffer.byteLength() twice. Small perf improvement Run 1: tls/convertprotocols.js n=1 v6.2.1 = 11852, new = 12204 ...... -2.89% tls/convertprotocols.js n=50000 v6.2.1 = 515660, new = 570610 ..... -9.63% Run 2: tls/convertprotocols.js n=1 v6.2.1 = 11729, new = 12045 ...... -2.62% tls/convertprotocols.js n=50000 v6.2.1 = 512080, new = 637730 ..... -19.70% PR-URL: https://github.com/nodejs/node/pull/7236 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Diffstat (limited to 'benchmark/tls')
-rw-r--r--benchmark/tls/convertprotocols.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/benchmark/tls/convertprotocols.js b/benchmark/tls/convertprotocols.js
new file mode 100644
index 0000000000..32da0fe6fd
--- /dev/null
+++ b/benchmark/tls/convertprotocols.js
@@ -0,0 +1,20 @@
+'use strict';
+
+const common = require('../common.js');
+const tls = require('tls');
+
+const bench = common.createBenchmark(main, {
+ n: [1, 50000]
+});
+
+function main(conf) {
+ const n = +conf.n;
+
+ var i = 0;
+ var m = {};
+ common.v8ForceOptimization(
+ tls.convertNPNProtocols, ['ABC', 'XYZ123', 'FOO'], m);
+ bench.start();
+ for (; i < n; i++) tls.convertNPNProtocols(['ABC', 'XYZ123', 'FOO'], m);
+ bench.end(n);
+}