From 0d390f7bdfe4f5e276a3bc240b80a1f8da2b69a2 Mon Sep 17 00:00:00 2001 From: Anatoli Papirovski Date: Thu, 1 Feb 2018 08:10:18 -0500 Subject: [PATCH] test: add test for tls benchmarks PR-URL: https://github.com/nodejs/node/pull/18489 Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- benchmark/tls/throughput.js | 2 +- test/sequential/test-benchmark-tls.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/sequential/test-benchmark-tls.js diff --git a/benchmark/tls/throughput.js b/benchmark/tls/throughput.js index f63257c49693d6..1ca52ad9496237 100644 --- a/benchmark/tls/throughput.js +++ b/benchmark/tls/throughput.js @@ -40,11 +40,11 @@ function main({ dur, type, size }) { }; server = tls.createServer(options, onConnection); - setTimeout(done, dur * 1000); var conn; server.listen(common.PORT, function() { const opt = { port: common.PORT, rejectUnauthorized: false }; conn = tls.connect(opt, function() { + setTimeout(done, dur * 1000); bench.start(); conn.on('drain', write); write(); diff --git a/test/sequential/test-benchmark-tls.js b/test/sequential/test-benchmark-tls.js new file mode 100644 index 00000000000000..7c87aa3cbcd89e --- /dev/null +++ b/test/sequential/test-benchmark-tls.js @@ -0,0 +1,25 @@ +'use strict'; + +const common = require('../common'); + +if (!common.enoughTestMem) + common.skip('Insufficient memory for TLS benchmark test'); + +// Because the TLS benchmarks use hardcoded ports, this should be in sequential +// rather than parallel to make sure it does not conflict with tests that choose +// random available ports. + +const runBenchmark = require('../common/benchmark'); + +runBenchmark('tls', + [ + 'concurrency=1', + 'dur=0.1', + 'n=1', + 'size=2', + 'type=asc' + ], + { + NODEJS_BENCHMARK_ZERO_ALLOWED: 1, + duration: 0 + });