mirror of https://github.com/nodejs/node.git
benchmark: add benchmark on async_hooks enabled http server
PR-URL: https://github.com/nodejs/node/pull/31100 Refs: https://github.com/nodejs/diagnostics/issues/124 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>pull/31100/merge
parent
2257e80902
commit
bf7265ffc6
|
@ -0,0 +1,40 @@
|
|||
'use strict';
|
||||
const common = require('../common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
asyncHooks: ['init', 'before', 'after', 'all', 'disabled', 'none'],
|
||||
connections: [50, 500]
|
||||
});
|
||||
|
||||
function main({ asyncHooks, connections }) {
|
||||
if (asyncHooks !== 'none') {
|
||||
let hooks = {
|
||||
init() {},
|
||||
before() {},
|
||||
after() {},
|
||||
destroy() {},
|
||||
promiseResolve() {}
|
||||
};
|
||||
if (asyncHooks !== 'all' || asyncHooks !== 'disabled') {
|
||||
hooks = {
|
||||
[asyncHooks]: () => {}
|
||||
};
|
||||
}
|
||||
const hook = require('async_hooks').createHook(hooks);
|
||||
if (asyncHooks !== 'disabled') {
|
||||
hook.enable();
|
||||
}
|
||||
}
|
||||
const server = require('../fixtures/simple-http-server.js')
|
||||
.listen(common.PORT)
|
||||
.on('listening', () => {
|
||||
const path = '/buffer/4/4/normal/1';
|
||||
|
||||
bench.http({
|
||||
connections,
|
||||
path,
|
||||
}, () => {
|
||||
server.close();
|
||||
});
|
||||
});
|
||||
}
|
|
@ -12,6 +12,8 @@ const runBenchmark = require('../common/benchmark');
|
|||
|
||||
runBenchmark('async_hooks',
|
||||
[
|
||||
'asyncHooks=all',
|
||||
'connections=50',
|
||||
'method=trackingDisabled',
|
||||
'n=10'
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue