mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 18:44:40 +00:00
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:
parent
8e42d8c7bf
commit
997c47fba7
@ -9,7 +9,6 @@ rules:
|
|||||||
|
|
||||||
overrides:
|
overrides:
|
||||||
- files:
|
- files:
|
||||||
- async_hooks/*.js
|
|
||||||
- buffers/*.js
|
- buffers/*.js
|
||||||
- buffers-fill/*.js
|
- buffers-fill/*.js
|
||||||
- crypto/*.js
|
- crypto/*.js
|
||||||
|
@ -3,7 +3,7 @@ const common = require('../common.js');
|
|||||||
const { AsyncLocalStorage } = require('async_hooks');
|
const { AsyncLocalStorage } = require('async_hooks');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [1e7]
|
n: [1e7],
|
||||||
});
|
});
|
||||||
|
|
||||||
async function run(store, n) {
|
async function run(store, n) {
|
||||||
|
@ -9,7 +9,7 @@ const {
|
|||||||
createHook,
|
createHook,
|
||||||
executionAsyncResource,
|
executionAsyncResource,
|
||||||
executionAsyncId,
|
executionAsyncId,
|
||||||
AsyncLocalStorage
|
AsyncLocalStorage,
|
||||||
} = require('async_hooks');
|
} = require('async_hooks');
|
||||||
const { createServer } = require('http');
|
const { createServer } = require('http');
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
path: '/',
|
path: '/',
|
||||||
connections: 500,
|
connections: 500,
|
||||||
duration: 5,
|
duration: 5,
|
||||||
n: [1e6]
|
n: [1e6],
|
||||||
});
|
});
|
||||||
|
|
||||||
function buildCurrentResource(getServe) {
|
function buildCurrentResource(getServe) {
|
||||||
@ -30,7 +30,7 @@ function buildCurrentResource(getServe) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
server,
|
server,
|
||||||
close
|
close,
|
||||||
};
|
};
|
||||||
|
|
||||||
function getCLS() {
|
function getCLS() {
|
||||||
@ -71,7 +71,7 @@ function buildDestroy(getServe) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
server,
|
server,
|
||||||
close
|
close,
|
||||||
};
|
};
|
||||||
|
|
||||||
function getCLS() {
|
function getCLS() {
|
||||||
@ -108,7 +108,7 @@ function buildAsyncLocalStorage(getServe) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
server,
|
server,
|
||||||
close
|
close,
|
||||||
};
|
};
|
||||||
|
|
||||||
function getCLS() {
|
function getCLS() {
|
||||||
@ -160,12 +160,12 @@ function getServeCallbacks(getCLS, setCLS) {
|
|||||||
const types = {
|
const types = {
|
||||||
'async-resource': buildCurrentResource,
|
'async-resource': buildCurrentResource,
|
||||||
'destroy': buildDestroy,
|
'destroy': buildDestroy,
|
||||||
'async-local-storage': buildAsyncLocalStorage
|
'async-local-storage': buildAsyncLocalStorage,
|
||||||
};
|
};
|
||||||
|
|
||||||
const asyncMethods = {
|
const asyncMethods = {
|
||||||
'callbacks': getServeCallbacks,
|
'callbacks': getServeCallbacks,
|
||||||
'async': getServeAwait
|
'async': getServeAwait,
|
||||||
};
|
};
|
||||||
|
|
||||||
function main({ type, asyncMethod, connections, duration, path }) {
|
function main({ type, asyncMethod, connections, duration, path }) {
|
||||||
@ -178,7 +178,7 @@ function main({ type, asyncMethod, connections, duration, path }) {
|
|||||||
bench.http({
|
bench.http({
|
||||||
path,
|
path,
|
||||||
connections,
|
connections,
|
||||||
duration
|
duration,
|
||||||
}, () => {
|
}, () => {
|
||||||
close();
|
close();
|
||||||
});
|
});
|
||||||
|
@ -8,9 +8,9 @@ const bench = common.createBenchmark(main, {
|
|||||||
'trackingEnabled',
|
'trackingEnabled',
|
||||||
'trackingEnabledWithDestroyHook',
|
'trackingEnabledWithDestroyHook',
|
||||||
'trackingDisabled',
|
'trackingDisabled',
|
||||||
]
|
],
|
||||||
}, {
|
}, {
|
||||||
flags: ['--expose-gc']
|
flags: ['--expose-gc'],
|
||||||
});
|
});
|
||||||
|
|
||||||
function endAfterGC(n) {
|
function endAfterGC(n) {
|
||||||
|
@ -4,7 +4,7 @@ const common = require('../common.js');
|
|||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
asyncHooks: ['init', 'before', 'after', 'all', 'disabled', 'none'],
|
asyncHooks: ['init', 'before', 'after', 'all', 'disabled', 'none'],
|
||||||
connections: [50, 500],
|
connections: [50, 500],
|
||||||
duration: 5
|
duration: 5,
|
||||||
});
|
});
|
||||||
|
|
||||||
function main({ asyncHooks, connections, duration }) {
|
function main({ asyncHooks, connections, duration }) {
|
||||||
@ -14,11 +14,11 @@ function main({ asyncHooks, connections, duration }) {
|
|||||||
before() {},
|
before() {},
|
||||||
after() {},
|
after() {},
|
||||||
destroy() {},
|
destroy() {},
|
||||||
promiseResolve() {}
|
promiseResolve() {},
|
||||||
};
|
};
|
||||||
if (asyncHooks !== 'all' || asyncHooks !== 'disabled') {
|
if (asyncHooks !== 'all' || asyncHooks !== 'disabled') {
|
||||||
hooks = {
|
hooks = {
|
||||||
[asyncHooks]: () => {}
|
[asyncHooks]: () => {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const hook = require('async_hooks').createHook(hooks);
|
const hook = require('async_hooks').createHook(hooks);
|
||||||
@ -34,7 +34,7 @@ function main({ asyncHooks, connections, duration }) {
|
|||||||
bench.http({
|
bench.http({
|
||||||
connections,
|
connections,
|
||||||
path,
|
path,
|
||||||
duration
|
duration,
|
||||||
}, () => {
|
}, () => {
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
|
@ -6,25 +6,25 @@ let hook;
|
|||||||
const tests = {
|
const tests = {
|
||||||
disabled() {
|
disabled() {
|
||||||
hook = createHook({
|
hook = createHook({
|
||||||
promiseResolve() {}
|
promiseResolve() {},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
enabled() {
|
enabled() {
|
||||||
hook = createHook({
|
hook = createHook({
|
||||||
promiseResolve() {}
|
promiseResolve() {},
|
||||||
}).enable();
|
}).enable();
|
||||||
},
|
},
|
||||||
enabledWithDestroy() {
|
enabledWithDestroy() {
|
||||||
hook = createHook({
|
hook = createHook({
|
||||||
promiseResolve() {},
|
promiseResolve() {},
|
||||||
destroy() {}
|
destroy() {},
|
||||||
}).enable();
|
}).enable();
|
||||||
},
|
},
|
||||||
enabledWithInitOnly() {
|
enabledWithInitOnly() {
|
||||||
hook = createHook({
|
hook = createHook({
|
||||||
init() {}
|
init() {},
|
||||||
}).enable();
|
}).enable();
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
@ -34,7 +34,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
'enabledWithDestroy',
|
'enabledWithDestroy',
|
||||||
'enabledWithInitOnly',
|
'enabledWithInitOnly',
|
||||||
'disabled',
|
'disabled',
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const err = new Error('foobar');
|
const err = new Error('foobar');
|
||||||
|
Loading…
Reference in New Issue
Block a user