Compare commits

...

4 Commits

Author SHA1 Message Date
Alexander Akait c48d17240f
Merge f95bc4e7b4 into 7634cd28bf 2025-10-06 15:34:37 +03:00
Alexander Akait 7634cd28bf
docs: update examples (#19982)
Github Actions / lint (push) Waiting to run Details
Github Actions / validate-legacy-node (push) Waiting to run Details
Github Actions / benchmark (1/4) (push) Waiting to run Details
Github Actions / benchmark (2/4) (push) Waiting to run Details
Github Actions / benchmark (3/4) (push) Waiting to run Details
Github Actions / benchmark (4/4) (push) Waiting to run Details
Github Actions / basic (push) Waiting to run Details
Github Actions / unit (push) Waiting to run Details
Github Actions / integration (10.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (10.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (10.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (12.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (14.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (16.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (18.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (20.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (20.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (lts/*, ubuntu-latest, a, 1) (push) Blocked by required conditions Details
Github Actions / integration (lts/*, ubuntu-latest, b, 1) (push) Blocked by required conditions Details
2025-10-06 15:29:40 +03:00
alexander-akait f95bc4e7b4 ci: debug codspeed 2025-10-04 14:48:57 +03:00
alexander-akait 0f668bd546 refactor: benchmarks 2025-10-04 14:37:41 +03:00
4 changed files with 62 additions and 49 deletions

View File

@ -103,6 +103,7 @@ jobs:
mode: "instrumentation" mode: "instrumentation"
token: ${{ secrets.CODSPEED_TOKEN }} token: ${{ secrets.CODSPEED_TOKEN }}
env: env:
CODSPEED_DEBUG: 1
LAST_COMMIT: 1 LAST_COMMIT: 1
NEGATIVE_FILTER: on-schedule NEGATIVE_FILTER: on-schedule
SHARD: ${{ matrix.shard }} SHARD: ${{ matrix.shard }}

View File

@ -300,7 +300,7 @@ module.exports = __webpack_require__.tb("PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmc
/******/ /******/
/******/ /* webpack/runtime/jsonp chunk loading */ /******/ /* webpack/runtime/jsonp chunk loading */
/******/ (() => { /******/ (() => {
/******/ __webpack_require__.b = (document && document.baseURI) || self.location.href; /******/ __webpack_require__.b = (typeof document !== 'undefined' && document.baseURI) || self.location.href;
/******/ /******/
/******/ // object to store loaded and loading chunks /******/ // object to store loaded and loading chunks
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
@ -476,10 +476,10 @@ files.forEach(item => {
asset output.js 19.2 KiB [emitted] (name: main) asset output.js 19.2 KiB [emitted] (name: main)
asset images/89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: images/file.png] (auxiliary name: main) asset images/89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: images/file.png] (auxiliary name: main)
asset images/afc10c70ed4ce2b33593.svg 656 bytes [emitted] [immutable] [from: images/url.svg] (auxiliary name: main) asset images/afc10c70ed4ce2b33593.svg 656 bytes [emitted] [immutable] [from: images/url.svg] (auxiliary name: main)
chunk (runtime: main) output.js (main) 12.4 KiB (javascript) 15.2 KiB (asset) 1.46 KiB (runtime) [entry] [rendered] chunk (runtime: main) output.js (main) 12.4 KiB (javascript) 15.2 KiB (asset) 1.48 KiB (runtime) [entry] [rendered]
> ./example.js main > ./example.js main
dependent modules 9.59 KiB (javascript) 15.2 KiB (asset) [dependent] 6 modules dependent modules 9.59 KiB (javascript) 15.2 KiB (asset) [dependent] 6 modules
runtime modules 1.46 KiB 5 modules runtime modules 1.48 KiB 5 modules
./example.js 2.85 KiB [built] [code generated] ./example.js 2.85 KiB [built] [code generated]
[no exports] [no exports]
[used exports unknown] [used exports unknown]

View File

@ -286,7 +286,7 @@ export const add = (content, from) => {
/******/ /******/
/******/ /* webpack/runtime/jsonp chunk loading */ /******/ /* webpack/runtime/jsonp chunk loading */
/******/ (() => { /******/ (() => {
/******/ __webpack_require__.b = (document && document.baseURI) || self.location.href; /******/ __webpack_require__.b = (typeof document !== 'undefined' && document.baseURI) || self.location.href;
/******/ /******/
/******/ // object to store loaded and loading chunks /******/ // object to store loaded and loading chunks
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
@ -722,7 +722,7 @@ function fibonacci(n) {
## Unoptimized ## Unoptimized
``` ```
asset main.js 11.8 KiB [emitted] (name: main) asset main.js 11.9 KiB [emitted] (name: main)
asset workers/fibonacci.js 4.99 KiB [emitted] (name: fibonacci) asset workers/fibonacci.js 4.99 KiB [emitted] (name: fibonacci)
asset chat.js 839 bytes [emitted] (name: chat) asset chat.js 839 bytes [emitted] (name: chat)
asset 129.js 741 bytes [emitted] asset 129.js 741 bytes [emitted]
@ -746,9 +746,9 @@ chunk (runtime: 9a81d90cfd0dfd13d748) workers/fibonacci.js (fibonacci) 176 bytes
./fib-worker.js 176 bytes [built] [code generated] ./fib-worker.js 176 bytes [built] [code generated]
[no exports used] [no exports used]
new Worker() ./fib-worker.js ./example.js 80:18-84:2 new Worker() ./fib-worker.js ./example.js 80:18-84:2
chunk (runtime: main) main.js (main) 2.25 KiB (javascript) 5.4 KiB (runtime) [entry] [rendered] chunk (runtime: main) main.js (main) 2.25 KiB (javascript) 5.42 KiB (runtime) [entry] [rendered]
> ./example.js main > ./example.js main
runtime modules 5.4 KiB 7 modules runtime modules 5.42 KiB 7 modules
./example.js 2.25 KiB [built] [code generated] ./example.js 2.25 KiB [built] [code generated]
[no exports used] [no exports used]
entry ./example.js main entry ./example.js main
@ -758,7 +758,7 @@ webpack X.X.X compiled successfully
## Production mode ## Production mode
``` ```
asset main.js 3.27 KiB [emitted] [minimized] (name: main) asset main.js 3.29 KiB [emitted] [minimized] (name: main)
asset workers/fibonacci.js 776 bytes [emitted] [minimized] (name: fibonacci) asset workers/fibonacci.js 776 bytes [emitted] [minimized] (name: fibonacci)
asset chat.js 270 bytes [emitted] [minimized] (name: chat) asset chat.js 270 bytes [emitted] [minimized] (name: chat)
asset 129.js 159 bytes [emitted] [minimized] asset 129.js 159 bytes [emitted] [minimized]
@ -782,9 +782,9 @@ chunk (runtime: 9a81d90cfd0dfd13d748) workers/fibonacci.js (fibonacci) 176 bytes
./fib-worker.js 176 bytes [built] [code generated] ./fib-worker.js 176 bytes [built] [code generated]
[no exports used] [no exports used]
new Worker() ./fib-worker.js ./example.js 80:18-84:2 new Worker() ./fib-worker.js ./example.js 80:18-84:2
chunk (runtime: main) main.js (main) 2.25 KiB (javascript) 5.4 KiB (runtime) [entry] [rendered] chunk (runtime: main) main.js (main) 2.25 KiB (javascript) 5.42 KiB (runtime) [entry] [rendered]
> ./example.js main > ./example.js main
runtime modules 5.4 KiB 7 modules runtime modules 5.42 KiB 7 modules
./example.js 2.25 KiB [built] [code generated] ./example.js 2.25 KiB [built] [code generated]
[no exports used] [no exports used]
entry ./example.js main entry ./example.js main

View File

@ -465,21 +465,6 @@ const withCodSpeed = async (/** @type {import("tinybench").Bench} */ bench) => {
const taskCompletionMessage = () => const taskCompletionMessage = () =>
InstrumentHooks.isInstrumented() ? "Measured" : "Checked"; InstrumentHooks.isInstrumented() ? "Measured" : "Checked";
const iterationAsync = async (task) => {
try {
await task.fnOpts.beforeEach?.call(task, "run");
const start = bench.opts.now();
await task.fn();
const end = bench.opts.now() - start || 0;
await task.fnOpts.afterEach?.call(this, "run");
return [start, end];
} catch (err) {
if (bench.opts.throws) {
throw err;
}
}
};
const wrapWithInstrumentHooksAsync = async (fn, uri) => { const wrapWithInstrumentHooksAsync = async (fn, uri) => {
InstrumentHooks.startBenchmark(); InstrumentHooks.startBenchmark();
const result = await fn(); const result = await fn();
@ -489,7 +474,29 @@ const withCodSpeed = async (/** @type {import("tinybench").Bench} */ bench) => {
}; };
const runTaskAsync = async (task, uri) => { const runTaskAsync = async (task, uri) => {
const { fnOpts, fn } = task; const { name, fn, fnOpts } = task;
const originalFn = fn;
const fnWrapper = async () => {
console.time(`Time: ${name}`);
await originalFn();
console.timeEnd(`Time: ${name}`);
};
const iterationAsync = async (task) => {
try {
await task.fnOpts.beforeEach?.call(task, "run");
const start = bench.opts.now();
await fnWrapper();
const end = bench.opts.now();
await task.fnOpts.afterEach?.call(this, "run");
return [start, end, end - start];
} catch (err) {
if (bench.opts.throws) {
throw err;
}
}
};
// Custom setup // Custom setup
await bench.opts.setup?.(task, "run"); await bench.opts.setup?.(task, "run");
@ -507,7 +514,10 @@ const withCodSpeed = async (/** @type {import("tinybench").Bench} */ bench) => {
await fnOpts?.beforeEach?.call(task, "run"); await fnOpts?.beforeEach?.call(task, "run");
await mongoMeasurement.start(uri); await mongoMeasurement.start(uri);
global.gc?.(); global.gc?.();
await wrapWithInstrumentHooksAsync(wrapFunctionWithFrame(fn, true), uri); await wrapWithInstrumentHooksAsync(
wrapFunctionWithFrame(fnWrapper, true),
uri
);
await mongoMeasurement.stop(uri); await mongoMeasurement.stop(uri);
await fnOpts?.afterEach?.call(task, "run"); await fnOpts?.afterEach?.call(task, "run");
console.log(`[Codspeed] ✔ Measured ${uri}`); console.log(`[Codspeed] ✔ Measured ${uri}`);
@ -519,21 +529,6 @@ const withCodSpeed = async (/** @type {import("tinybench").Bench} */ bench) => {
logTaskCompletion(uri, taskCompletionMessage()); logTaskCompletion(uri, taskCompletionMessage());
}; };
const iteration = (task) => {
try {
task.fnOpts.beforeEach?.call(task, "run");
const start = bench.opts.now();
task.fn();
const end = bench.opts.now() - start || 0;
task.fnOpts.afterEach?.call(this, "run");
return [start, end];
} catch (err) {
if (bench.opts.throws) {
throw err;
}
}
};
const wrapWithInstrumentHooks = (fn, uri) => { const wrapWithInstrumentHooks = (fn, uri) => {
InstrumentHooks.startBenchmark(); InstrumentHooks.startBenchmark();
const result = fn(); const result = fn();
@ -543,7 +538,29 @@ const withCodSpeed = async (/** @type {import("tinybench").Bench} */ bench) => {
}; };
const runTaskSync = (task, uri) => { const runTaskSync = (task, uri) => {
const { fnOpts, fn } = task; const { name, fnOpts, fn } = task;
const originalFn = fn;
const fnWrapper = () => {
console.time(`Time: ${name}`);
originalFn();
console.timeEnd(`Time: ${name}`);
};
const iteration = (task) => {
try {
task.fnOpts.beforeEach?.call(task, "run");
const start = bench.opts.now();
task.fn();
const end = bench.opts.now() - start || 0;
task.fnOpts.afterEach?.call(this, "run");
return [start, end];
} catch (err) {
if (bench.opts.throws) {
throw err;
}
}
};
// Custom setup // Custom setup
bench.opts.setup?.(task, "run"); bench.opts.setup?.(task, "run");
@ -559,7 +576,7 @@ const withCodSpeed = async (/** @type {import("tinybench").Bench} */ bench) => {
fnOpts?.beforeEach?.call(task, "run"); fnOpts?.beforeEach?.call(task, "run");
wrapWithInstrumentHooks(wrapFunctionWithFrame(fn, false), uri); wrapWithInstrumentHooks(wrapFunctionWithFrame(fnWrapper, false), uri);
fnOpts?.afterEach?.call(task, "run"); fnOpts?.afterEach?.call(task, "run");
console.log(`[Codspeed] ✔ Measured ${uri}`); console.log(`[Codspeed] ✔ Measured ${uri}`);
@ -693,8 +710,6 @@ async function registerSuite(bench, test, baselines) {
bench.add( bench.add(
benchName, benchName,
async () => { async () => {
console.time(`Time: ${benchName}`);
let resolve; let resolve;
let reject; let reject;
@ -717,7 +732,6 @@ async function registerSuite(bench, test, baselines) {
// Construct and print stats to be more accurate with real life projects // Construct and print stats to be more accurate with real life projects
stats.toString(); stats.toString();
resolve(); resolve();
console.timeEnd(`Time: ${benchName}`);
}; };
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
@ -836,9 +850,7 @@ async function registerSuite(bench, test, baselines) {
runWebpack(webpack, config) runWebpack(webpack, config)
); );
} else { } else {
console.time(`Time: ${benchName}`);
await runWebpack(webpack, config); await runWebpack(webpack, config);
console.timeEnd(`Time: ${benchName}`);
} }
}, },
{ {