11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common.js'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 51cb0ef41Sopenharmony_ci asyncHooks: ['init', 'before', 'after', 'all', 'disabled', 'none'], 61cb0ef41Sopenharmony_ci connections: [50, 500], 71cb0ef41Sopenharmony_ci duration: 5, 81cb0ef41Sopenharmony_ci}); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_cifunction main({ asyncHooks, connections, duration }) { 111cb0ef41Sopenharmony_ci if (asyncHooks !== 'none') { 121cb0ef41Sopenharmony_ci let hooks = { 131cb0ef41Sopenharmony_ci init() {}, 141cb0ef41Sopenharmony_ci before() {}, 151cb0ef41Sopenharmony_ci after() {}, 161cb0ef41Sopenharmony_ci destroy() {}, 171cb0ef41Sopenharmony_ci promiseResolve() {}, 181cb0ef41Sopenharmony_ci }; 191cb0ef41Sopenharmony_ci if (asyncHooks !== 'all' || asyncHooks !== 'disabled') { 201cb0ef41Sopenharmony_ci hooks = { 211cb0ef41Sopenharmony_ci [asyncHooks]: () => {}, 221cb0ef41Sopenharmony_ci }; 231cb0ef41Sopenharmony_ci } 241cb0ef41Sopenharmony_ci const hook = require('async_hooks').createHook(hooks); 251cb0ef41Sopenharmony_ci if (asyncHooks !== 'disabled') { 261cb0ef41Sopenharmony_ci hook.enable(); 271cb0ef41Sopenharmony_ci } 281cb0ef41Sopenharmony_ci } 291cb0ef41Sopenharmony_ci const server = require('../fixtures/simple-http-server.js') 301cb0ef41Sopenharmony_ci .listen(common.PORT) 311cb0ef41Sopenharmony_ci .on('listening', () => { 321cb0ef41Sopenharmony_ci const path = '/buffer/4/4/normal/1'; 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci bench.http({ 351cb0ef41Sopenharmony_ci connections, 361cb0ef41Sopenharmony_ci path, 371cb0ef41Sopenharmony_ci duration, 381cb0ef41Sopenharmony_ci }, () => { 391cb0ef41Sopenharmony_ci server.close(); 401cb0ef41Sopenharmony_ci }); 411cb0ef41Sopenharmony_ci }); 421cb0ef41Sopenharmony_ci} 43