-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
benchmark: add benchmark on async_hooks enabled http server
PR-URL: #31100 Refs: nodejs/diagnostics#124 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
5bf2772
commit 827d3fe
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} | ||
}; | ||
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(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters