benchmark: add test and all options and improve errors"

This reverts commit 4671d551cf and
contains a fix to the issue raised for the revert.

PR-URL: https://github.com/nodejs/node/pull/31755
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Ruben Bridgewater 2020-02-12 19:33:33 +01:00
parent f64aafa2d5
commit 1760c23f75
No known key found for this signature in database
GPG key ID: F07496B3EB3C1762
38 changed files with 306 additions and 201 deletions

View file

@ -13,14 +13,12 @@ const {
} = require('async_hooks');
const { createServer } = require('http');
// Configuration for the http server
// there is no need for parameters in this test
const connections = 500;
const path = '/';
const bench = common.createBenchmark(main, {
type: ['async-resource', 'destroy', 'async-local-storage'],
asyncMethod: ['callbacks', 'async'],
path: '/',
connections: 500,
duration: 5,
n: [1e6]
});
@ -165,7 +163,7 @@ const asyncMethods = {
'async': getServeAwait
};
function main({ type, asyncMethod }) {
function main({ type, asyncMethod, connections, duration, path }) {
const { server, close } = types[type](asyncMethods[asyncMethod]);
server
@ -174,7 +172,8 @@ function main({ type, asyncMethod }) {
bench.http({
path,
connections
connections,
duration
}, () => {
close();
});