Skip to content

Commit

Permalink
benchmark: add benchmark on async_hooks enabled http server
Browse files Browse the repository at this point in the history
  • Loading branch information
legendecas committed Jan 1, 2020
1 parent c052113 commit 500b240
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
34 changes: 34 additions & 0 deletions benchmark/async_hooks/http-server.js
@@ -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();
});
});
}
4 changes: 3 additions & 1 deletion test/benchmark/test-benchmark-async-hooks.js
Expand Up @@ -13,6 +13,8 @@ const runBenchmark = require('../common/benchmark');
runBenchmark('async_hooks',
[
'method=trackingDisabled',
'n=10'
'n=10',
'asyncHooks=enabled',
'c=50'
],
{});

0 comments on commit 500b240

Please sign in to comment.