Skip to content
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
Prev Previous commit
Next Next commit
fixup! benchmark: add benchmark on async_hooks enabled http server
  • Loading branch information
legendecas committed Jan 1, 2020
commit 75a1603755c07de3de533bd55153812fd1f558ee
22 changes: 14 additions & 8 deletions benchmark/async_hooks/http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@
const common = require('../common.js');

const bench = common.createBenchmark(main, {
asyncHooks: ['enabed', 'disabled', 'none'],
c: [50, 500]
asyncHooks: ['init', 'before', 'after', 'all', 'disabled', 'none'],
connections: [50, 500]
});

function main({ asyncHooks, c }) {
function main({ asyncHooks, connections }) {
if (asyncHooks !== 'none') {
const hook = require('async_hooks').createHook({
let hooks = {
init() {},
before() {},
after() {},
destroy() {},
promiseResolve() {}
Comment thread
BridgeAR marked this conversation as resolved.
});
if (asyncHooks === 'enabed') {
};
if (asyncHooks !== 'all' || asyncHooks !== 'disabled') {
hooks = {
[asyncHooks]: () => {}
};
}
const hook = require('async_hooks').createHook(hooks);
if (asyncHooks !== 'disabled') {
hook.enable();
}
}
Expand All @@ -25,8 +31,8 @@ function main({ asyncHooks, c }) {
const path = '/buffer/4/4/normal/1';

bench.http({
path: path,
connections: c
connections,
path,
}, () => {
server.close();
});
Expand Down
4 changes: 2 additions & 2 deletions test/benchmark/test-benchmark-async-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runBenchmark('async_hooks',
[
'method=trackingDisabled',
'n=10',
'asyncHooks=enabled',
'c=50'
'asyncHooks=all',
'connections=50'
Comment thread
BridgeAR marked this conversation as resolved.
Outdated
],
{});