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
- Loading branch information
1 parent
c052113
commit 500b240
Showing
2 changed files
with
37 additions
and
1 deletion.
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,34 @@ | ||
'use strict'; | ||
const common = require('../common.js'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
asyncHooks: ['enabed', 'disabled', 'none'], | ||
c: [50, 500] | ||
}); | ||
|
||
function main({ asyncHooks, c }) { | ||
if (asyncHooks !== 'none') { | ||
const hook = require('async_hooks').createHook({ | ||
init() {}, | ||
before() {}, | ||
after() {}, | ||
destroy() {}, | ||
promiseResolve() {} | ||
}); | ||
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(); | ||
}); | ||
}); | ||
} |
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