benchmark: add trailing commas in benchmark/async_hooks

PR-URL: https://github.com/nodejs/node/pull/46424
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
Antoine du Hamel 2023-02-01 22:46:09 +01:00 committed by GitHub
parent 8e42d8c7bf
commit 997c47fba7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 22 deletions

View File

@ -9,7 +9,6 @@ rules:
overrides:
- files:
- async_hooks/*.js
- buffers/*.js
- buffers-fill/*.js
- crypto/*.js

View File

@ -3,7 +3,7 @@ const common = require('../common.js');
const { AsyncLocalStorage } = require('async_hooks');
const bench = common.createBenchmark(main, {
n: [1e7]
n: [1e7],
});
async function run(store, n) {

View File

@ -9,7 +9,7 @@ const {
createHook,
executionAsyncResource,
executionAsyncId,
AsyncLocalStorage
AsyncLocalStorage,
} = require('async_hooks');
const { createServer } = require('http');
@ -19,7 +19,7 @@ const bench = common.createBenchmark(main, {
path: '/',
connections: 500,
duration: 5,
n: [1e6]
n: [1e6],
});
function buildCurrentResource(getServe) {
@ -30,7 +30,7 @@ function buildCurrentResource(getServe) {
return {
server,
close
close,
};
function getCLS() {
@ -71,7 +71,7 @@ function buildDestroy(getServe) {
return {
server,
close
close,
};
function getCLS() {
@ -108,7 +108,7 @@ function buildAsyncLocalStorage(getServe) {
return {
server,
close
close,
};
function getCLS() {
@ -160,12 +160,12 @@ function getServeCallbacks(getCLS, setCLS) {
const types = {
'async-resource': buildCurrentResource,
'destroy': buildDestroy,
'async-local-storage': buildAsyncLocalStorage
'async-local-storage': buildAsyncLocalStorage,
};
const asyncMethods = {
'callbacks': getServeCallbacks,
'async': getServeAwait
'async': getServeAwait,
};
function main({ type, asyncMethod, connections, duration, path }) {
@ -178,7 +178,7 @@ function main({ type, asyncMethod, connections, duration, path }) {
bench.http({
path,
connections,
duration
duration,
}, () => {
close();
});

View File

@ -8,9 +8,9 @@ const bench = common.createBenchmark(main, {
'trackingEnabled',
'trackingEnabledWithDestroyHook',
'trackingDisabled',
]
],
}, {
flags: ['--expose-gc']
flags: ['--expose-gc'],
});
function endAfterGC(n) {

View File

@ -4,7 +4,7 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, {
asyncHooks: ['init', 'before', 'after', 'all', 'disabled', 'none'],
connections: [50, 500],
duration: 5
duration: 5,
});
function main({ asyncHooks, connections, duration }) {
@ -14,11 +14,11 @@ function main({ asyncHooks, connections, duration }) {
before() {},
after() {},
destroy() {},
promiseResolve() {}
promiseResolve() {},
};
if (asyncHooks !== 'all' || asyncHooks !== 'disabled') {
hooks = {
[asyncHooks]: () => {}
[asyncHooks]: () => {},
};
}
const hook = require('async_hooks').createHook(hooks);
@ -34,7 +34,7 @@ function main({ asyncHooks, connections, duration }) {
bench.http({
connections,
path,
duration
duration,
}, () => {
server.close();
});

View File

@ -6,25 +6,25 @@ let hook;
const tests = {
disabled() {
hook = createHook({
promiseResolve() {}
promiseResolve() {},
});
},
enabled() {
hook = createHook({
promiseResolve() {}
promiseResolve() {},
}).enable();
},
enabledWithDestroy() {
hook = createHook({
promiseResolve() {},
destroy() {}
destroy() {},
}).enable();
},
enabledWithInitOnly() {
hook = createHook({
init() {}
init() {},
}).enable();
}
},
};
const bench = common.createBenchmark(main, {
@ -34,7 +34,7 @@ const bench = common.createBenchmark(main, {
'enabledWithDestroy',
'enabledWithInitOnly',
'disabled',
]
],
});
const err = new Error('foobar');