diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-08-13 12:29:07 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-08-13 12:29:22 +0200 |
commit | da736d8259331a8ef13bf4bbb10bbb8a5c0e5299 (patch) | |
tree | 4d849133b1c9a9c7067e96ff7dd8faa1d927e0bb /deps/node/benchmark/tls | |
parent | da228cf9d71b747f1824e85127039e5afc7effd8 (diff) | |
download | akono-da736d8259331a8ef13bf4bbb10bbb8a5c0e5299.tar.gz akono-da736d8259331a8ef13bf4bbb10bbb8a5c0e5299.tar.bz2 akono-da736d8259331a8ef13bf4bbb10bbb8a5c0e5299.zip |
remove node/v8 from source tree
Diffstat (limited to 'deps/node/benchmark/tls')
-rw-r--r-- | deps/node/benchmark/tls/convertprotocols.js | 22 | ||||
-rw-r--r-- | deps/node/benchmark/tls/secure-pair.js | 105 | ||||
-rw-r--r-- | deps/node/benchmark/tls/throughput.js | 72 | ||||
-rw-r--r-- | deps/node/benchmark/tls/tls-connect.js | 68 |
4 files changed, 0 insertions, 267 deletions
diff --git a/deps/node/benchmark/tls/convertprotocols.js b/deps/node/benchmark/tls/convertprotocols.js deleted file mode 100644 index 0ba6c6dd..00000000 --- a/deps/node/benchmark/tls/convertprotocols.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const tls = require('tls'); - -const bench = common.createBenchmark(main, { - n: [1, 50000] -}); - -function main({ n }) { - const input = ['ABC', 'XYZ123', 'FOO']; - var m = {}; - // First call dominates results - if (n > 1) { - tls.convertALPNProtocols(input, m); - m = {}; - } - bench.start(); - for (var i = 0; i < n; i++) - tls.convertALPNProtocols(input, m); - bench.end(n); -} diff --git a/deps/node/benchmark/tls/secure-pair.js b/deps/node/benchmark/tls/secure-pair.js deleted file mode 100644 index ed678b90..00000000 --- a/deps/node/benchmark/tls/secure-pair.js +++ /dev/null @@ -1,105 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - dur: [5], - securing: ['SecurePair', 'TLSSocket'], - size: [2, 1024, 1024 * 1024] -}); - -const fs = require('fs'); -const tls = require('tls'); -const net = require('net'); -const path = require('path'); - -const cert_dir = path.resolve(__dirname, '../../test/fixtures'); -const REDIRECT_PORT = 28347; - -function main({ dur, size, securing }) { - const chunk = Buffer.alloc(size, 'b'); - - const options = { - key: fs.readFileSync(`${cert_dir}/test_key.pem`), - cert: fs.readFileSync(`${cert_dir}/test_cert.pem`), - ca: [ fs.readFileSync(`${cert_dir}/test_ca.pem`) ], - ciphers: 'AES256-GCM-SHA384', - isServer: true, - requestCert: true, - rejectUnauthorized: true, - }; - - const server = net.createServer(onRedirectConnection); - server.listen(REDIRECT_PORT, () => { - const proxy = net.createServer(onProxyConnection); - proxy.listen(common.PORT, () => { - const clientOptions = { - port: common.PORT, - ca: options.ca, - key: options.key, - cert: options.cert, - isServer: false, - rejectUnauthorized: false, - }; - const conn = tls.connect(clientOptions, () => { - setTimeout(() => { - const mbits = (received * 8) / (1024 * 1024); - bench.end(mbits); - if (conn) - conn.destroy(); - server.close(); - proxy.close(); - }, dur * 1000); - bench.start(); - conn.on('drain', write); - write(); - }); - conn.on('error', (e) => { - throw new Error(`Client error: ${e}`); - }); - - function write() { - while (false !== conn.write(chunk)); - } - }); - }); - - function onProxyConnection(conn) { - const client = net.connect(REDIRECT_PORT, () => { - switch (securing) { - case 'SecurePair': - securePair(conn, client); - break; - case 'TLSSocket': - secureTLSSocket(conn, client); - break; - default: - throw new Error('Invalid securing method'); - } - }); - } - - function securePair(conn, client) { - const serverCtx = tls.createSecureContext(options); - const serverPair = tls.createSecurePair(serverCtx, true, true, false); - conn.pipe(serverPair.encrypted); - serverPair.encrypted.pipe(conn); - serverPair.on('error', (error) => { - throw new Error(`Pair error: ${error}`); - }); - serverPair.cleartext.pipe(client); - } - - function secureTLSSocket(conn, client) { - const serverSocket = new tls.TLSSocket(conn, options); - serverSocket.on('error', (e) => { - throw new Error(`Socket error: ${e}`); - }); - serverSocket.pipe(client); - } - - let received = 0; - function onRedirectConnection(conn) { - conn.on('data', (chunk) => { - received += chunk.length; - }); - } -} diff --git a/deps/node/benchmark/tls/throughput.js b/deps/node/benchmark/tls/throughput.js deleted file mode 100644 index 3c0c2d4e..00000000 --- a/deps/node/benchmark/tls/throughput.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - dur: [5], - type: ['buf', 'asc', 'utf'], - size: [2, 1024, 1024 * 1024] -}); - -const path = require('path'); -const fs = require('fs'); -const cert_dir = path.resolve(__dirname, '../../test/fixtures'); -var options; -const tls = require('tls'); - -function main({ dur, type, size }) { - var encoding; - var server; - var chunk; - switch (type) { - case 'buf': - chunk = Buffer.alloc(size, 'b'); - break; - case 'asc': - chunk = 'a'.repeat(size); - encoding = 'ascii'; - break; - case 'utf': - chunk = 'ΓΌ'.repeat(size / 2); - encoding = 'utf8'; - break; - default: - throw new Error('invalid type'); - } - - options = { - key: fs.readFileSync(`${cert_dir}/test_key.pem`), - cert: fs.readFileSync(`${cert_dir}/test_cert.pem`), - ca: [ fs.readFileSync(`${cert_dir}/test_ca.pem`) ], - ciphers: 'AES256-GCM-SHA384' - }; - - server = tls.createServer(options, onConnection); - var conn; - server.listen(common.PORT, () => { - const opt = { port: common.PORT, rejectUnauthorized: false }; - conn = tls.connect(opt, () => { - setTimeout(done, dur * 1000); - bench.start(); - conn.on('drain', write); - write(); - }); - - function write() { - while (false !== conn.write(chunk, encoding)); - } - }); - - var received = 0; - function onConnection(conn) { - conn.on('data', (chunk) => { - received += chunk.length; - }); - } - - function done() { - const mbits = (received * 8) / (1024 * 1024); - bench.end(mbits); - if (conn) - conn.destroy(); - server.close(); - } -} diff --git a/deps/node/benchmark/tls/tls-connect.js b/deps/node/benchmark/tls/tls-connect.js deleted file mode 100644 index 470d536f..00000000 --- a/deps/node/benchmark/tls/tls-connect.js +++ /dev/null @@ -1,68 +0,0 @@ -'use strict'; -const fs = require('fs'); -const path = require('path'); -const tls = require('tls'); - -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - concurrency: [1, 10], - dur: [5] -}); - -var clientConn = 0; -var serverConn = 0; -var dur; -var concurrency; -var running = true; - -function main(conf) { - dur = conf.dur; - concurrency = conf.concurrency; - const cert_dir = path.resolve(__dirname, '../../test/fixtures'); - const options = { - key: fs.readFileSync(`${cert_dir}/test_key.pem`), - cert: fs.readFileSync(`${cert_dir}/test_cert.pem`), - ca: [ fs.readFileSync(`${cert_dir}/test_ca.pem`) ], - ciphers: 'AES256-GCM-SHA384' - }; - - const server = tls.createServer(options, onConnection); - server.listen(common.PORT, onListening); -} - -function onListening() { - setTimeout(done, dur * 1000); - bench.start(); - for (var i = 0; i < concurrency; i++) - makeConnection(); -} - -function onConnection(conn) { - serverConn++; -} - -function makeConnection() { - const options = { - port: common.PORT, - rejectUnauthorized: false - }; - var conn = tls.connect(options, () => { - clientConn++; - conn.on('error', (er) => { - console.error('client error', er); - throw er; - }); - conn.end(); - if (running) makeConnection(); - }); -} - -function done() { - running = false; - // It's only an established connection if they both saw it. - // because we destroy the server somewhat abruptly, these - // don't always match. Generally, serverConn will be - // the smaller number, but take the min just to be sure. - bench.end(Math.min(serverConn, clientConn)); - process.exit(0); -} |