Skip to content

Commit

Permalink
benchmark: add trailing commas in benchmark/async_hooks
Browse files Browse the repository at this point in the history
PR-URL: #46424
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
  • Loading branch information
aduh95 authored and danielleadams committed Apr 3, 2023
1 parent 534562f commit f006b2f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
1 change: 0 additions & 1 deletion benchmark/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ rules:

overrides:
- files:
- async_hooks/*.js
- buffers/*.js
- buffers-fill/*.js
- crypto/*.js
Expand Down
2 changes: 1 addition & 1 deletion benchmark/async_hooks/async-local-storage-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 8 additions & 8 deletions benchmark/async_hooks/async-resource-vs-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {
createHook,
executionAsyncResource,
executionAsyncId,
AsyncLocalStorage
AsyncLocalStorage,
} = require('async_hooks');
const { createServer } = require('http');

Expand All @@ -19,7 +19,7 @@ const bench = common.createBenchmark(main, {
path: '/',
connections: 500,
duration: 5,
n: [1e6]
n: [1e6],
});

function buildCurrentResource(getServe) {
Expand All @@ -30,7 +30,7 @@ function buildCurrentResource(getServe) {

return {
server,
close
close,
};

function getCLS() {
Expand Down Expand Up @@ -71,7 +71,7 @@ function buildDestroy(getServe) {

return {
server,
close
close,
};

function getCLS() {
Expand Down Expand Up @@ -108,7 +108,7 @@ function buildAsyncLocalStorage(getServe) {

return {
server,
close
close,
};

function getCLS() {
Expand Down Expand Up @@ -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 }) {
Expand All @@ -178,7 +178,7 @@ function main({ type, asyncMethod, connections, duration, path }) {
bench.http({
path,
connections,
duration
duration,
}, () => {
close();
});
Expand Down
4 changes: 2 additions & 2 deletions benchmark/async_hooks/gc-tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const bench = common.createBenchmark(main, {
'trackingEnabled',
'trackingEnabledWithDestroyHook',
'trackingDisabled',
]
],
}, {
flags: ['--expose-gc']
flags: ['--expose-gc'],
});

function endAfterGC(n) {
Expand Down
8 changes: 4 additions & 4 deletions benchmark/async_hooks/http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand All @@ -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);
Expand All @@ -34,7 +34,7 @@ function main({ asyncHooks, connections, duration }) {
bench.http({
connections,
path,
duration
duration,
}, () => {
server.close();
});
Expand Down
12 changes: 6 additions & 6 deletions benchmark/async_hooks/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -34,7 +34,7 @@ const bench = common.createBenchmark(main, {
'enabledWithDestroy',
'enabledWithInitOnly',
'disabled',
]
],
});

const err = new Error('foobar');
Expand Down

0 comments on commit f006b2f

Please sign in to comment.