Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark: add benchmark on async_hooks enabled http server #31100

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 40 additions & 0 deletions benchmark/async_hooks/http-server.js
@@ -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() {}
BridgeAR marked this conversation as resolved.
Show resolved Hide resolved
};
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();
});
});
}
4 changes: 3 additions & 1 deletion test/benchmark/test-benchmark-async-hooks.js
Expand Up @@ -13,6 +13,8 @@ const runBenchmark = require('../common/benchmark');
runBenchmark('async_hooks',
[
'method=trackingDisabled',
'n=10'
'n=10',
'asyncHooks=all',
'connections=50'
BridgeAR marked this conversation as resolved.
Show resolved Hide resolved
],
{});