Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b48cfcc

Browse filesBrowse files
legendecastargos
authored andcommitted
benchmark: add benchmark on async_hooks enabled http server
PR-URL: #31100 Refs: nodejs/diagnostics#124 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 7aa7759 commit b48cfcc
Copy full SHA for b48cfcc

File tree

Expand file treeCollapse file tree

2 files changed

+42
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

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

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

Copy file name to clipboardExpand all lines: test/benchmark/test-benchmark-async-hooks.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const runBenchmark = require('../common/benchmark');
1212

1313
runBenchmark('async_hooks',
1414
[
15+
'asyncHooks=all',
16+
'connections=50',
1517
'method=trackingDisabled',
1618
'n=10'
1719
],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.