diff --git a/package.json b/package.json index f2c8efc682af4..1ed7700bc6bc2 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,8 @@ "pyodide@0.23.4": "patches/pyodide@0.23.4.patch", "@types/express-serve-static-core@4.17.43": "patches/@types__express-serve-static-core@4.17.43.patch", "@types/ws@8.5.4": "patches/@types__ws@8.5.4.patch", - "vite-plugin-checker@0.6.4": "patches/vite-plugin-checker@0.6.4.patch" + "vite-plugin-checker@0.6.4": "patches/vite-plugin-checker@0.6.4.patch", + "@codspeed/tinybench-plugin@3.1.0": "patches/@codspeed__tinybench-plugin@3.1.0.patch" } } } diff --git a/packages/cli/src/benchmark/lib/api.ts b/packages/cli/src/benchmark/lib/api.ts index 3a23463370c88..b4bbbc83a4551 100644 --- a/packages/cli/src/benchmark/lib/api.ts +++ b/packages/cli/src/benchmark/lib/api.ts @@ -24,7 +24,7 @@ export async function collectSuites() { } export function registerSuites(bench: Bench) { - for (const { hooks, tasks } of Object.values(suites)) { + for (const { name: suiteName, hooks, tasks } of Object.values(suites)) { /** * In tinybench, `beforeAll` and `afterAll` refer to all _iterations_ of * a single task, while `beforeEach` and `afterEach` refer to each _iteration_. @@ -40,7 +40,9 @@ export function registerSuites(bench: Bench) { if (hooks.afterEachTask) options.afterAll = hooks.afterEachTask; for (const t of tasks) { - bench.add(t.name, t.operation, options); + const taskName = process.env.CI === 'true' ? [suiteName, t.name].join('::') : t.name; + + bench.add(taskName, t.operation, options); } } } diff --git a/patches/@codspeed__tinybench-plugin@3.1.0.patch b/patches/@codspeed__tinybench-plugin@3.1.0.patch new file mode 100644 index 0000000000000..ce4f38306e2a3 --- /dev/null +++ b/patches/@codspeed__tinybench-plugin@3.1.0.patch @@ -0,0 +1,18 @@ +diff --git a/dist/index.cjs.js b/dist/index.cjs.js +index a75964e40eaeff15df33fabd3c0bef20e9b1e5dd..42f2bec4950f13675ddccba675b2c207b2789d42 100644 +--- a/dist/index.cjs.js ++++ b/dist/index.cjs.js +@@ -80,7 +80,12 @@ function withCodSpeed(bench) { + const rawAdd = bench.add; + bench.add = (name, fn, opts) => { + const callingFile = getCallingFile(); +- const uri = `${callingFile}::${name}`; ++ let uri = `${callingFile}::${name}`; ++ if (name.includes('::')) { ++ // ignore calling file misdirecting to benchmark/lib/api.js ++ const [suiteName, taskName] = name.split('::'); ++ uri = `${suiteName} - ${taskName}` ++ } + const options = Object.assign({}, opts ?? {}, { uri }); + return rawAdd.bind(bench)(name, fn, options); + }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3b3f95ac100e0..a9bae4f7c81fa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,6 +19,9 @@ overrides: typescript: ^5.4.2 patchedDependencies: + '@codspeed/tinybench-plugin@3.1.0': + hash: dtpxhamve6ldymzame6xpj4atq + path: patches/@codspeed__tinybench-plugin@3.1.0.patch '@sentry/cli@2.17.0': hash: nchnoezkq6p37qaiku3vrpwraq path: patches/@sentry__cli@2.17.0.patch @@ -759,7 +762,7 @@ importers: devDependencies: '@codspeed/tinybench-plugin': specifier: ^3.1.0 - version: 3.1.0(tinybench@2.6.0) + version: 3.1.0(patch_hash=dtpxhamve6ldymzame6xpj4atq)(tinybench@2.6.0) '@redocly/cli': specifier: ^1.6.0 version: 1.6.0 @@ -4726,7 +4729,7 @@ packages: - debug dev: true - /@codspeed/tinybench-plugin@3.1.0(tinybench@2.6.0): + /@codspeed/tinybench-plugin@3.1.0(patch_hash=dtpxhamve6ldymzame6xpj4atq)(tinybench@2.6.0): resolution: {integrity: sha512-yl0WzzUGIXkZzWaw7+2U+xGkuIal1Rs9hS09DtlDZGGAcGRoMMU5d2vyCS8nBrna4hrPQZ5Sx/hIKerO+lqWaw==} peerDependencies: tinybench: ^2.3.0 @@ -4737,6 +4740,7 @@ packages: transitivePeerDependencies: - debug dev: true + patched: true /@colors/colors@1.5.0: resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} @@ -9227,7 +9231,7 @@ packages: ts-dedent: 2.2.0 type-fest: 2.19.0 vue: 3.4.21(typescript@5.4.2) - vue-component-type-helpers: 2.0.14 + vue-component-type-helpers: 2.0.15 transitivePeerDependencies: - encoding - supports-color @@ -25853,8 +25857,8 @@ packages: resolution: {integrity: sha512-0vOfAtI67UjeO1G6UiX5Kd76CqaQ67wrRZiOe7UAb9Jm6GzlUr/fC7CV90XfwapJRjpCMaZFhv1V0ajWRmE9Dg==} dev: true - /vue-component-type-helpers@2.0.14: - resolution: {integrity: sha512-DInfgOyXlMyliyqAAD9frK28tTfch0+tMi4qoWJcZlRxUf+NFAtraJBnAsKLep+FOyLMiajkhfyEb3xLK08i7w==} + /vue-component-type-helpers@2.0.15: + resolution: {integrity: sha512-jR/Hw52gzNQxMovJBsOQ/F9E1UQ8K1Np0CVG3RnueLkaCKqWuyL9XHl/5tUBAGJx+bk5xZ+co7vK23+Pzt75Lg==} dev: true /vue-demi@0.14.5(vue@3.4.21):