Skip to content

Commit 500b240

Browse files
committed
benchmark: add benchmark on async_hooks enabled http server
1 parent c052113 commit 500b240

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

benchmark/async_hooks/http-server.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
const common = require('../common.js');
3+
4+
const bench = common.createBenchmark(main, {
5+
asyncHooks: ['enabed', 'disabled', 'none'],
6+
c: [50, 500]
7+
});
8+
9+
function main({ asyncHooks, c }) {
10+
if (asyncHooks !== 'none') {
11+
const hook = require('async_hooks').createHook({
12+
init() {},
13+
before() {},
14+
after() {},
15+
destroy() {},
16+
promiseResolve() {}
17+
});
18+
if (asyncHooks === 'enabed') {
19+
hook.enable();
20+
}
21+
}
22+
const server = require('../fixtures/simple-http-server.js')
23+
.listen(common.PORT)
24+
.on('listening', () => {
25+
const path = '/buffer/4/4/normal/1';
26+
27+
bench.http({
28+
path: path,
29+
connections: c
30+
}, () => {
31+
server.close();
32+
});
33+
});
34+
}

test/benchmark/test-benchmark-async-hooks.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const runBenchmark = require('../common/benchmark');
1313
runBenchmark('async_hooks',
1414
[
1515
'method=trackingDisabled',
16-
'n=10'
16+
'n=10',
17+
'asyncHooks=enabled',
18+
'c=50'
1719
],
1820
{});

0 commit comments

Comments
 (0)