diff --git a/benchmark/async_hooks/http-server.js b/benchmark/async_hooks/http-server.js new file mode 100644 index 00000000000000..2b5094e51cc17b --- /dev/null +++ b/benchmark/async_hooks/http-server.js @@ -0,0 +1,34 @@ +'use strict'; +const common = require('../common.js'); + +const bench = common.createBenchmark(main, { + asyncHooks: ['enabed', 'disabled', 'none'], + c: [50, 500] +}); + +function main({ asyncHooks, c }) { + if (asyncHooks !== 'none') { + const hook = require('async_hooks').createHook({ + init() {}, + before() {}, + after() {}, + destroy() {}, + promiseResolve() {} + }); + if (asyncHooks === 'enabed') { + hook.enable(); + } + } + const server = require('../fixtures/simple-http-server.js') + .listen(common.PORT) + .on('listening', () => { + const path = '/buffer/4/4/normal/1'; + + bench.http({ + path: path, + connections: c + }, () => { + server.close(); + }); + }); +} diff --git a/test/benchmark/test-benchmark-async-hooks.js b/test/benchmark/test-benchmark-async-hooks.js index 4cb6f89a8c70e3..218f647102c47c 100644 --- a/test/benchmark/test-benchmark-async-hooks.js +++ b/test/benchmark/test-benchmark-async-hooks.js @@ -13,6 +13,8 @@ const runBenchmark = require('../common/benchmark'); runBenchmark('async_hooks', [ 'method=trackingDisabled', - 'n=10' + 'n=10', + 'asyncHooks=enabled', + 'c=50' ], {});