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 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
benchmark: add benchmark on async_hooks enabled http server
  • Loading branch information
legendecas committed Jan 1, 2020
commit 500b240e5a9178985eab801a6408939ea0b6488b
34 changes: 34 additions & 0 deletions benchmark/async_hooks/http-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';
const common = require('../common.js');

const bench = common.createBenchmark(main, {
asyncHooks: ['enabed', 'disabled', 'none'],
c: [50, 500]
BridgeAR marked this conversation as resolved.
Show resolved Hide resolved
});

function main({ asyncHooks, c }) {
if (asyncHooks !== 'none') {
const hook = require('async_hooks').createHook({
init() {},
before() {},
after() {},
destroy() {},
promiseResolve() {}
BridgeAR marked this conversation as resolved.
Show resolved Hide resolved
});
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();
});
});
}
4 changes: 3 additions & 1 deletion test/benchmark/test-benchmark-async-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const runBenchmark = require('../common/benchmark');
runBenchmark('async_hooks',
[
'method=trackingDisabled',
'n=10'
'n=10',
'asyncHooks=enabled',
'c=50'
],
{});