-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: #7236 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
- Loading branch information
1 parent
2c7804a
commit 77331a7
Showing
2 changed files
with
31 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters