| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5bf2772 commit 827d3fe
2 files changed
| Original file line number | Diff line number | Diff 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 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,8 @@ const runBenchmark = require('../common/benchmark'); | |||
| 12 | 12 | ||
| 13 | 13 | runBenchmark('async_hooks', | |
| 14 | 14 | [ | |
| 15 | + 'asyncHooks=all', | ||
| 16 | + 'connections=50', | ||
| 15 | 17 | 'method=trackingDisabled', | |
| 16 | 18 | 'n=10' | |
| 17 | 19 | ], | |
| Back | FazBrowse Home | New Git URL |
0 commit comments