lib: refactor tls options handle in https.js#27118
Closed
gengjiawen wants to merge 1 commit intonodejs:masterfrom
Closed
lib: refactor tls options handle in https.js#27118gengjiawen wants to merge 1 commit intonodejs:masterfrom
gengjiawen wants to merge 1 commit intonodejs:masterfrom
Conversation
52841ee to
0057d90
Compare
Member
|
@gengjiawen a for loop was not used for performance reasons. See discussion in #16402. |
Member
Author
Looks like 2x diff (Node node: '12.0.0-pre', v8: '7.3.492.25-node.7') es\arrary-vs-invidual.js mode="Array" n=1000: 263,026.3123632099
es\arrary-vs-invidual.js mode="Invidual" n=1000: 469,417.45294090034Details'use strict';
const common = require('../common.js');
const configs = {
n: [1e3],
mode: ['Array', 'Invidual']
};
const bench = common.createBenchmark(main, configs);
function main({ n, mode }) {
switch (mode) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'Array':
bench.start();
for (let i = 0; i < n; i++)
useArray();
bench.end(n);
break;
case 'Invidual':
bench.start();
for (let i = 0; i < n; i++)
useInvidual();
bench.end(n);
break;
default:
throw new Error(`Unexpected method "${mode}"`);
}
}
function useArray() {
let name = '';
let options = {};
const options_keys = [
'ca',
'cert',
'ciphers',
'clientCertEngine',
'crl',
'dhparam',
'ecdhCurve',
'honorCipherOrder',
'key',
'maxVersion',
'minVersion',
'pfx',
'rejectUnauthorized',
'secureOptions',
'secureProtocol',
'sessionIdContext'
];
options_keys.forEach((i) => {
name += ':';
if (options[i]) {
name += options[i];
}
});
name += ':';
if (options.servername && options.servername !== options.host)
name += options.servername;
return name;
}
function useInvidual() {
let name = '';
let options = {};
name += ':';
if (options.ca)
name += options.ca;
name += ':';
if (options.cert)
name += options.cert;
name += ':';
if (options.clientCertEngine)
name += options.clientCertEngine;
name += ':';
if (options.ciphers)
name += options.ciphers;
name += ':';
if (options.key)
name += options.key;
name += ':';
if (options.pfx)
name += options.pfx;
name += ':';
if (options.rejectUnauthorized !== undefined)
name += options.rejectUnauthorized;
name += ':';
if (options.servername && options.servername !== options.host)
name += options.servername;
name += ':';
if (options.minVersion)
name += options.minVersion;
name += ':';
if (options.maxVersion)
name += options.maxVersion;
name += ':';
if (options.secureProtocol)
name += options.secureProtocol;
name += ':';
if (options.crl)
name += options.crl;
name += ':';
if (options.honorCipherOrder !== undefined)
name += options.honorCipherOrder;
name += ':';
if (options.ecdhCurve)
name += options.ecdhCurve;
name += ':';
if (options.dhparam)
name += options.dhparam;
name += ':';
if (options.secureOptions !== undefined)
name += options.secureOptions;
name += ':';
if (options.sessionIdContext)
name += options.sessionIdContext;
return name;
} |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes