From 816402ebc813fd2d1a7a36fdde45e0087bf966b8 Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Thu, 8 Sep 2022 11:43:13 +0300 Subject: [PATCH] docs: add information about benchmark --- .gitignore | 1 + docs/api/index.md | 115 ++++++++- docs/config/index.md | 36 +++ docs/guide/features.md | 24 ++ .../src/node/reporters/benchmark/json.ts | 10 +- packages/vitest/src/types/benchmark.ts | 2 +- pnpm-lock.yaml | 233 +++++++++++++++--- test/benchmark/package.json | 2 +- test/benchmark/test.mjs | 18 ++ test/benchmark/test/mode.bench.ts | 11 + 10 files changed, 409 insertions(+), 43 deletions(-) create mode 100644 test/benchmark/test.mjs create mode 100644 test/benchmark/test/mode.bench.ts diff --git a/.gitignore b/.gitignore index 6c53c3a54331..e91c60c4cb51 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ dist ltex* .DS_Store bench/test/*/*/ +**/benchmark/bench.json cypress/videos cypress/downloads cypress/screenshots diff --git a/docs/api/index.md b/docs/api/index.md index 94666f493f7c..fd254600fece 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -212,11 +212,98 @@ In Jest, `TestFunction` can also be of type `(done: DoneCallback) => void`. If t If you want to have access to `TestContext`, use `describe.each` with a single test. +## bench + +- **Type:** `(name: string, fn: BenchFunction, options?: BenchOptions) => void` + +`bench` defines a benchmark. In Vitest terms benchmark is a function that defines a series of operations. Vitest runs this function multiple times to display different performance results. + +Vitest uses [`tinybench`](https://github.com/tinylibs/tinybench) library under the hood, inheriting all its options that can be used as a third argument. + + ```ts + import { bench } from 'vitest' + + bench('normal sorting', () => { + const x = [1, 5, 4, 2, 3] + x.sort((a, b) => { + return a - b + }) + }, { time: 1000 }) + ``` + + ```ts + export interface Options { + /** + * time needed for running a benchmark task (milliseconds) + * @default 500 + */ + time?: number + + /** + * number of times that a task should run if even the time option is finished + * @default 10 + */ + iterations?: number + + /** + * function to get the current timestamp in milliseconds + */ + now?: () => number + + /** + * An AbortSignal for aborting the benchmark + */ + signal?: AbortSignal + + /** + * warmup time (milliseconds) + * @default 100ms + */ + warmupTime?: number + + /** + * warmup iterations + * @default 5 + */ + warmupIterations?: number + + /** + * setup function to run before each benchmark task (cycle) + */ + setup?: Hook + + /** + * teardown function to run after each benchmark task (cycle) + */ + teardown?: Hook + } + ``` + +### bench.skip + +- **Type:** `(name: string, fn: BenchFunction, options?: BenchOptions) => void` + +You can use `bench.skip` syntax to skip running certain benchmarks. + + ```ts + import { bench } from 'vitest' + + bench.skip('normal sorting', () => { + const x = [1, 5, 4, 2, 3] + x.sort((a, b) => { + return a - b + }) + }) + ``` + ## describe -When you use `test` in the top level of file, they are collected as part of the implicit suite for it. Using `describe` you can define a new suite in the current context, as a set of related tests and other nested suites. A suite lets you organize your tests so reports are more clear. +When you use `test` or `bench` in the top level of file, they are collected as part of the implicit suite for it. Using `describe` you can define a new suite in the current context, as a set of related tests or benchmarks and other nested suites. A suite lets you organize your tests and benchmarks so reports are more clear. ```ts + // basic.spec.ts + // organizing tests + import { describe, expect, test } from 'vitest' const person = { @@ -239,7 +326,30 @@ When you use `test` in the top level of file, they are collected as part of the }) ``` - You can also nest describe blocks if you have a hierarchy of tests: + ```ts + // basic.bench.ts + // organizing benchmarks + + import { bench, describe } from 'vitest' + + describe('sort', () => { + bench('normal', () => { + const x = [1, 5, 4, 2, 3] + x.sort((a, b) => { + return a - b + }) + }) + + bench('reverse', () => { + const x = [1, 5, 4, 2, 3] + x.reverse().sort((a, b) => { + return a - b + }) + }) + }) + ``` + + You can also nest describe blocks if you have a hierarchy of tests or benchmarks: ```ts import { describe, expect, test } from 'vitest' @@ -360,6 +470,7 @@ When you use `test` in the top level of file, they are collected as part of the // An entry will be shown in the report for this suite describe.todo('unimplemented suite') ``` + ### describe.each - **Type:** `(cases: ReadonlyArray): (name: string, fn: (...args: T[]) => void) => void` diff --git a/docs/config/index.md b/docs/config/index.md index 00ed5cd393c3..471b6d8c8886 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -132,6 +132,42 @@ If disabled, your `alias` and `.resolveId` won't affect imports inside ` Interpret CJS module's default as named exports. +### benchmark + +- **Type:** `{ include?, exclude?, ... }` + +Options used when running `vitest bench`. + +### benchmark.include + +- **Type:** `string[]` +- **Default:** `['**/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']` + +Include globs for benchmark test files + +### benchmark.exclude + +- **Type:** `string[]` +- **Default:** `['node_modules', 'dist', '.idea', '.git', '.cache']` + +Exclude globs for benchmark test files + +### benchmark.includeSource + +- **Type:** `string[]` +- **Default:** `[]` + +Include globs for in-source benchmark test files. This option is similar to [`includeSource`](#includesource). + +When defined, Vitest will run all matched files with `import.meta.vitest` inside. + +### benchmark.reporters + +- **Type:** `Arrayable` +- **Default:** `'default'` + +Custom reporter for output. Can contain one or more built-in report names, reporter instances, and/or paths to custom reporters. + ### alias - **Type:** `Record | Array<{ find: string | RegExp, replacement: string, customResolver?: ResolverFunction | ResolverObject }>` diff --git a/docs/guide/features.md b/docs/guide/features.md index b7ae12f1071a..4193da0f5ae3 100644 --- a/docs/guide/features.md +++ b/docs/guide/features.md @@ -175,3 +175,27 @@ if (import.meta.vitest) { ``` Learn more at [In-source testing](/guide/in-source). + +## Benchmarking experimental + +Since Vitest 0.23.0, you can run benchmark tests with [`bench`](/api/#bench) function to compare performance results. + +```ts +import { bench, describe } from 'vitest' + +describe('sort', () => { + bench('normal', () => { + const x = [1, 5, 4, 2, 3] + x.sort((a, b) => { + return a - b + }) + }) + + bench('reverse', () => { + const x = [1, 5, 4, 2, 3] + x.reverse().sort((a, b) => { + return a - b + }) + }) +}) +``` diff --git a/packages/vitest/src/node/reporters/benchmark/json.ts b/packages/vitest/src/node/reporters/benchmark/json.ts index d85735666adc..ddd3c1b705f4 100644 --- a/packages/vitest/src/node/reporters/benchmark/json.ts +++ b/packages/vitest/src/node/reporters/benchmark/json.ts @@ -29,16 +29,16 @@ export class JsonReporter implements Reporter { for (const file of files) { const tests = getTests([file]) for (const test of tests) { - const res = test.result!.benchmark! + const res = test.result?.benchmark + if (!res || test.mode === 'skip') // TODO mark as skipped + continue if (!outputFile) res.samples = 'ignore on terminal' as any - testResults[test.suite.name] = (testResults[test.suite.name] || []).concat(res) } - // test.suite.name if (tests.some(t => t.result?.state === 'run')) { - this.ctx.logger.warn('WARNING: Some tests are still running when generating the markdown report.' + this.ctx.logger.warn('WARNING: Some tests are still running when generating the json report.' + 'This is likely an internal bug in Vitest.' + 'Please report it to https://github.com/vitest-dev/vitest/issues') } @@ -73,7 +73,7 @@ export class JsonReporter implements Reporter { await fs.mkdir(outputDirectory, { recursive: true }) await fs.writeFile(reportFile, report, 'utf-8') - this.ctx.logger.log(`markdown report written to ${reportFile}`) + this.ctx.logger.log(`json report written to ${reportFile}`) } else { this.ctx.logger.log(report) diff --git a/packages/vitest/src/types/benchmark.ts b/packages/vitest/src/types/benchmark.ts index 9d8a1af98e88..39b46df21103 100644 --- a/packages/vitest/src/types/benchmark.ts +++ b/packages/vitest/src/types/benchmark.ts @@ -18,7 +18,7 @@ export interface BenchmarkUserOptions { exclude?: string[] /** - * Include globs for in-source test files + * Include globs for in-source benchmark test files * * @default [] */ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6f4d984a5b77..fcedb90cb826 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -93,7 +93,7 @@ importers: typescript: 4.8.2 vite: 3.0.9 vitest: link:packages/vitest - vue: 3.2.38 + vue: 3.2.39 docs: specifiers: @@ -113,18 +113,18 @@ importers: vue: latest workbox-window: ^6.5.4 dependencies: - '@vueuse/core': 9.1.1_vue@3.2.38 + '@vueuse/core': 9.1.1_vue@3.2.39 jiti: 1.14.0 - vue: 3.2.38 + vue: 3.2.39 devDependencies: '@iconify-json/carbon': 1.1.7 '@unocss/reset': 0.45.15 - '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.38 + '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.39 esno: 0.16.3 fast-glob: 3.2.11 https-localhost: 4.7.1 unocss: 0.45.15_vite@3.0.9 - unplugin-vue-components: 0.22.4_vite@3.0.9+vue@3.2.38 + unplugin-vue-components: 0.22.4_vite@3.0.9+vue@3.2.39 vite: 3.0.9 vite-plugin-pwa: 0.12.6_f7se6o6eqkwcix4u3svh6mkvda vitepress: 1.0.0-alpha.13 @@ -237,7 +237,7 @@ importers: react-dom: 18.0.0_react@18.0.0 devDependencies: '@testing-library/react': 13.3.0_zpnidt7m3osuk7shl3s4oenomq - '@types/node': 18.7.15 + '@types/node': 18.7.16 '@types/react': 18.0.18 '@vitejs/plugin-react': 2.1.0 jsdom: 20.0.0 @@ -494,13 +494,13 @@ importers: vitest: workspace:* vue: latest devDependencies: - '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.38 - '@vue/test-utils': 2.0.2_vue@3.2.38 + '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.39 + '@vue/test-utils': 2.0.2_vue@3.2.39 jsdom: 20.0.0 vite: 3.0.9 vite-plugin-ruby: 3.1.2_vite@3.0.9 vitest: link:../../packages/vitest - vue: 3.2.38 + vue: 3.2.39 examples/solid: specifiers: @@ -546,13 +546,13 @@ importers: vitest: workspace:* vue: latest dependencies: - vue: 3.2.38 + vue: 3.2.39 devDependencies: - '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.38 - '@vue/test-utils': 2.0.2_vue@3.2.38 + '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.39 + '@vue/test-utils': 2.0.2_vue@3.2.39 jsdom: 20.0.0 unplugin-auto-import: 0.11.2_vite@3.0.9 - unplugin-vue-components: 0.22.4_vite@3.0.9+vue@3.2.38 + unplugin-vue-components: 0.22.4_vite@3.0.9+vue@3.2.39 vite: 3.0.9 vitest: link:../../packages/vitest @@ -565,10 +565,10 @@ importers: vitest: workspace:* vue: latest dependencies: - vue: 3.2.38 + vue: 3.2.39 devDependencies: - '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.38 - '@vue/test-utils': 2.0.0_vue@3.2.38 + '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.39 + '@vue/test-utils': 2.0.0_vue@3.2.39 jsdom: 20.0.0 vite: 3.0.9 vitest: link:../../packages/vitest @@ -583,13 +583,13 @@ importers: vitest: workspace:* vue: latest devDependencies: - '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.38 - '@vitejs/plugin-vue-jsx': 2.0.1_vite@3.0.9+vue@3.2.38 - '@vue/test-utils': 2.0.2_vue@3.2.38 + '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.39 + '@vitejs/plugin-vue-jsx': 2.0.1_vite@3.0.9+vue@3.2.39 + '@vue/test-utils': 2.0.2_vue@3.2.39 jsdom: 20.0.0 vite: 3.0.9 vitest: link:../../packages/vitest - vue: 3.2.38 + vue: 3.2.39 examples/vue2: specifiers: @@ -952,12 +952,12 @@ importers: vitest: workspace:* vue: latest devDependencies: - '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.38 - '@vue/test-utils': 2.0.2_vue@3.2.38 + '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.39 + '@vue/test-utils': 2.0.2_vue@3.2.39 happy-dom: 6.0.4 vite: 3.0.9 vitest: link:../../packages/vitest - vue: 3.2.38 + vue: 3.2.39 test/css: specifiers: @@ -5849,6 +5849,10 @@ packages: resolution: {integrity: sha512-XnjpaI8Bgc3eBag2Aw4t2Uj/49lLBSStHWfqKvIuXD7FIrZyMLWp8KuAFHAqxMZYTF9l08N1ctUn9YNybZJVmQ==} dev: true + /@types/node/18.7.16: + resolution: {integrity: sha512-EQHhixfu+mkqHMZl1R2Ovuvn47PUw18azMJOTwSZr9/fhzHNGXAJ0ma0dayRVchprpCj0Kc1K1xKoWaATWF1qg==} + dev: true + /@types/node/8.10.66: resolution: {integrity: sha512-tktOkFUA4kXx2hhhrB8bIFb5TbwzS4uOhKEmwiD+NoiL0qtP2OQ9mFldbgD4dV1djrlBYP6eBuQZiWjuHUpqFw==} dev: true @@ -6406,6 +6410,23 @@ packages: - supports-color dev: true + /@vitejs/plugin-vue-jsx/2.0.1_vite@3.0.9+vue@3.2.39: + resolution: {integrity: sha512-lmiR1k9+lrF7LMczO0pxtQ8mOn6XeppJDHxnpxkJQpT5SiKz4SKhKdeNstXaTNuR8qZhUo5X0pJlcocn72Y4Jg==} + engines: {node: ^14.18.0 || >=16.0.0} + peerDependencies: + vite: ^3.0.0 + vue: ^3.0.0 + dependencies: + '@babel/core': 7.18.13 + '@babel/plugin-syntax-import-meta': 7.10.4_@babel+core@7.18.13 + '@babel/plugin-transform-typescript': 7.18.12_@babel+core@7.18.13 + '@vue/babel-plugin-jsx': 1.1.1_@babel+core@7.18.13 + vite: 3.0.9 + vue: 3.2.39 + transitivePeerDependencies: + - supports-color + dev: true + /@vitejs/plugin-vue/3.0.3_vite@3.0.9+vue@3.2.38: resolution: {integrity: sha512-U4zNBlz9mg+TA+i+5QPc3N5lQvdUXENZLO2h0Wdzp56gI1MWhqJOv+6R+d4kOzoaSSq6TnGPBdZAXKOe4lXy6g==} engines: {node: ^14.18.0 || >=16.0.0} @@ -6417,7 +6438,7 @@ packages: vue: 3.2.38 dev: true - /@vitejs/plugin-vue/3.1.0_vite@3.0.9+vue@3.2.38: + /@vitejs/plugin-vue/3.1.0_vite@3.0.9+vue@3.2.39: resolution: {integrity: sha512-fmxtHPjSOEIRg6vHYDaem+97iwCUg/uSIaTzp98lhELt2ISOQuDo2hbkBdXod0g15IhfPMQmAxh4heUks2zvDA==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: @@ -6425,7 +6446,7 @@ packages: vue: ^3.2.25 dependencies: vite: 3.0.9 - vue: 3.2.38 + vue: 3.2.39 dev: true /@vitejs/plugin-vue2/1.1.2_vite@3.0.9+vue@2.7.10: @@ -6467,12 +6488,28 @@ packages: '@vue/shared': 3.2.38 estree-walker: 2.0.2 source-map: 0.6.1 + dev: true + + /@vue/compiler-core/3.2.39: + resolution: {integrity: sha512-mf/36OWXqWn0wsC40nwRRGheR/qoID+lZXbIuLnr4/AngM0ov8Xvv8GHunC0rKRIkh60bTqydlqTeBo49rlbqw==} + dependencies: + '@babel/parser': 7.18.13 + '@vue/shared': 3.2.39 + estree-walker: 2.0.2 + source-map: 0.6.1 /@vue/compiler-dom/3.2.38: resolution: {integrity: sha512-zqX4FgUbw56kzHlgYuEEJR8mefFiiyR3u96498+zWPsLeh1WKvgIReoNE+U7gG8bCUdvsrJ0JRmev0Ky6n2O0g==} dependencies: '@vue/compiler-core': 3.2.38 '@vue/shared': 3.2.38 + dev: true + + /@vue/compiler-dom/3.2.39: + resolution: {integrity: sha512-HMFI25Be1C8vLEEv1hgEO1dWwG9QQ8LTTPmCkblVJY/O3OvWx6r1+zsox5mKPMGvqYEZa6l8j+xgOfUspgo7hw==} + dependencies: + '@vue/compiler-core': 3.2.39 + '@vue/shared': 3.2.39 /@vue/compiler-sfc/2.7.10: resolution: {integrity: sha512-55Shns6WPxlYsz4WX7q9ZJBL77sKE1ZAYNYStLs6GbhIOMrNtjMvzcob6gu3cGlfpCR4bT7NXgyJ3tly2+Hx8Q==} @@ -6494,12 +6531,34 @@ packages: magic-string: 0.25.9 postcss: 8.4.16 source-map: 0.6.1 + dev: true + + /@vue/compiler-sfc/3.2.39: + resolution: {integrity: sha512-fqAQgFs1/BxTUZkd0Vakn3teKUt//J3c420BgnYgEOoVdTwYpBTSXCMJ88GOBCylmUBbtquGPli9tVs7LzsWIA==} + dependencies: + '@babel/parser': 7.18.13 + '@vue/compiler-core': 3.2.39 + '@vue/compiler-dom': 3.2.39 + '@vue/compiler-ssr': 3.2.39 + '@vue/reactivity-transform': 3.2.39 + '@vue/shared': 3.2.39 + estree-walker: 2.0.2 + magic-string: 0.25.9 + postcss: 8.4.16 + source-map: 0.6.1 /@vue/compiler-ssr/3.2.38: resolution: {integrity: sha512-bm9jOeyv1H3UskNm4S6IfueKjUNFmi2kRweFIGnqaGkkRePjwEcfCVqyS3roe7HvF4ugsEkhf4+kIvDhip6XzQ==} dependencies: '@vue/compiler-dom': 3.2.38 '@vue/shared': 3.2.38 + dev: true + + /@vue/compiler-ssr/3.2.39: + resolution: {integrity: sha512-EoGCJ6lincKOZGW+0Ky4WOKsSmqL7hp1ZYgen8M7u/mlvvEQUaO9tKKOy7K43M9U2aA3tPv0TuYYQFrEbK2eFQ==} + dependencies: + '@vue/compiler-dom': 3.2.39 + '@vue/shared': 3.2.39 /@vue/devtools-api/6.2.1: resolution: {integrity: sha512-OEgAMeQXvCoJ+1x8WyQuVZzFo0wcyCmUR3baRVLmKBo1LmYZWMlRiXlux5jd0fqVJu6PfDbOrZItVqUEzLobeQ==} @@ -6513,17 +6572,40 @@ packages: '@vue/shared': 3.2.38 estree-walker: 2.0.2 magic-string: 0.25.9 + dev: true + + /@vue/reactivity-transform/3.2.39: + resolution: {integrity: sha512-HGuWu864zStiWs9wBC6JYOP1E00UjMdDWIG5W+FpUx28hV3uz9ODOKVNm/vdOy/Pvzg8+OcANxAVC85WFBbl3A==} + dependencies: + '@babel/parser': 7.18.13 + '@vue/compiler-core': 3.2.39 + '@vue/shared': 3.2.39 + estree-walker: 2.0.2 + magic-string: 0.25.9 /@vue/reactivity/3.2.38: resolution: {integrity: sha512-6L4myYcH9HG2M25co7/BSo0skKFHpAN8PhkNPM4xRVkyGl1K5M3Jx4rp5bsYhvYze2K4+l+pioN4e6ZwFLUVtw==} dependencies: '@vue/shared': 3.2.38 + dev: true + + /@vue/reactivity/3.2.39: + resolution: {integrity: sha512-vlaYX2a3qMhIZfrw3Mtfd+BuU+TZmvDrPMa+6lpfzS9k/LnGxkSuf0fhkP0rMGfiOHPtyKoU9OJJJFGm92beVQ==} + dependencies: + '@vue/shared': 3.2.39 /@vue/runtime-core/3.2.38: resolution: {integrity: sha512-kk0qiSiXUU/IKxZw31824rxmFzrLr3TL6ZcbrxWTKivadoKupdlzbQM4SlGo4MU6Zzrqv4fzyUasTU1jDoEnzg==} dependencies: '@vue/reactivity': 3.2.38 '@vue/shared': 3.2.38 + dev: true + + /@vue/runtime-core/3.2.39: + resolution: {integrity: sha512-xKH5XP57JW5JW+8ZG1khBbuLakINTgPuINKL01hStWLTTGFOrM49UfCFXBcFvWmSbci3gmJyLl2EAzCaZWsx8g==} + dependencies: + '@vue/reactivity': 3.2.39 + '@vue/shared': 3.2.39 /@vue/runtime-dom/3.2.38: resolution: {integrity: sha512-4PKAb/ck2TjxdMSzMsnHViOrrwpudk4/A56uZjhzvusoEU9xqa5dygksbzYepdZeB5NqtRw5fRhWIiQlRVK45A==} @@ -6531,6 +6613,14 @@ packages: '@vue/runtime-core': 3.2.38 '@vue/shared': 3.2.38 csstype: 2.6.20 + dev: true + + /@vue/runtime-dom/3.2.39: + resolution: {integrity: sha512-4G9AEJP+sLhsqf5wXcyKVWQKUhI+iWfy0hWQgea+CpaTD7BR0KdQzvoQdZhwCY6B3oleSyNLkLAQwm0ya/wNoA==} + dependencies: + '@vue/runtime-core': 3.2.39 + '@vue/shared': 3.2.39 + csstype: 2.6.20 /@vue/server-renderer/3.2.38_vue@3.2.38: resolution: {integrity: sha512-pg+JanpbOZ5kEfOZzO2bt02YHd+ELhYP8zPeLU1H0e7lg079NtuuSB8fjLdn58c4Ou8UQ6C1/P+528nXnLPAhA==} @@ -6540,9 +6630,23 @@ packages: '@vue/compiler-ssr': 3.2.38 '@vue/shared': 3.2.38 vue: 3.2.38 + dev: true + + /@vue/server-renderer/3.2.39_vue@3.2.39: + resolution: {integrity: sha512-1yn9u2YBQWIgytFMjz4f/t0j43awKytTGVptfd3FtBk76t1pd8mxbek0G/DrnjJhd2V7mSTb5qgnxMYt8Z5iSQ==} + peerDependencies: + vue: 3.2.39 + dependencies: + '@vue/compiler-ssr': 3.2.39 + '@vue/shared': 3.2.39 + vue: 3.2.39 /@vue/shared/3.2.38: resolution: {integrity: sha512-dTyhTIRmGXBjxJE+skC8tTWCGLCVc4wQgRRLt8+O9p5ewBAjoBwtCAkLPrtToSr1xltoe3st21Pv953aOZ7alg==} + dev: true + + /@vue/shared/3.2.39: + resolution: {integrity: sha512-D3dl2ZB9qE6mTuWPk9RlhDeP1dgNRUKC3NJxji74A4yL8M2MwlhLKUC/49WHjrNzSPug58fWx/yFbaTzGAQSBw==} /@vue/test-utils/1.3.0_42puyn3dcxirnpdjnosl7pbb6a: resolution: {integrity: sha512-Xk2Xiyj2k5dFb8eYUKkcN9PzqZSppTlx7LaQWBbdA8tqh3jHr/KHX2/YLhNFc/xwDrgeLybqd+4ZCPJSGPIqeA==} @@ -6557,20 +6661,20 @@ packages: vue-template-compiler: 2.7.10 dev: true - /@vue/test-utils/2.0.0_vue@3.2.38: + /@vue/test-utils/2.0.0_vue@3.2.39: resolution: {integrity: sha512-zL5kygNq7hONrO1CzaUGprEAklAX+pH8J1MPMCU3Rd2xtSYkZ+PmKU3oEDRg8VAGdL5lNJHzDgrud5amFPtirw==} peerDependencies: vue: ^3.0.1 dependencies: - vue: 3.2.38 + vue: 3.2.39 dev: true - /@vue/test-utils/2.0.2_vue@3.2.38: + /@vue/test-utils/2.0.2_vue@3.2.39: resolution: {integrity: sha512-E2P4oXSaWDqTZNbmKZFVLrNN/siVN78YkEqs7pHryWerrlZR9bBFLWdJwRoguX45Ru6HxIflzKl4vQvwRMwm5g==} peerDependencies: vue: ^3.0.1 dependencies: - vue: 3.2.38 + vue: 3.2.39 dev: true /@vueuse/core/8.9.4: @@ -6600,6 +6704,18 @@ packages: transitivePeerDependencies: - '@vue/composition-api' - vue + dev: true + + /@vueuse/core/9.1.1_vue@3.2.39: + resolution: {integrity: sha512-QfuaNWRDMQcCUwXylCyYhPC3ScS9Tiiz4J0chdwr3vOemBwRToSywq8MP+ZegKYFnbETzRY8G/5zC+ca30wrRQ==} + dependencies: + '@types/web-bluetooth': 0.0.15 + '@vueuse/metadata': 9.1.1 + '@vueuse/shared': 9.1.1_vue@3.2.39 + vue-demi: 0.12.5_vue@3.2.39 + transitivePeerDependencies: + - '@vue/composition-api' + - vue /@vueuse/integrations/8.9.4_axios@0.26.1: resolution: {integrity: sha512-Nk7mH0ThTdiuiiuB+1lyC+5ihnywrr+9h9IA4R4Ry8Mli/cZL38zc3qZWIsCVPm66Lr+7kEp3nnHdSxKi7ivrg==} @@ -6673,6 +6789,15 @@ packages: transitivePeerDependencies: - '@vue/composition-api' - vue + dev: true + + /@vueuse/shared/9.1.1_vue@3.2.39: + resolution: {integrity: sha512-c+IfcOYmHiHqoEa3ED1Tbpue5GHmoUmTp8PtO4YbczthtY155Rt6DmWhjxMLXBF1Bcidagxljmp/7xtAzEHXLw==} + dependencies: + vue-demi: 0.13.11_vue@3.2.39 + transitivePeerDependencies: + - '@vue/composition-api' + - vue /@webassemblyjs/ast/1.11.1: resolution: {integrity: sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==} @@ -18419,7 +18544,7 @@ packages: - webpack dev: true - /unplugin-vue-components/0.22.4_vite@3.0.9+vue@3.2.38: + /unplugin-vue-components/0.22.4_vite@3.0.9+vue@3.2.39: resolution: {integrity: sha512-2rRZcM9OnJGXnYxQNfaceEYuPeVACcWySIjy8WBwIiN3onr980TmA3XE5pRJFt8zoQrUA+c46oyIq96noLqrEQ==} engines: {node: '>=14'} peerDependencies: @@ -18439,7 +18564,7 @@ packages: minimatch: 5.1.0 resolve: 1.22.1 unplugin: 0.9.5_vite@3.0.9 - vue: 3.2.38 + vue: 3.2.39 transitivePeerDependencies: - esbuild - rollup @@ -18795,13 +18920,13 @@ packages: dependencies: '@docsearch/css': 3.2.1 '@docsearch/js': 3.2.1 - '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.38 + '@vitejs/plugin-vue': 3.1.0_vite@3.0.9+vue@3.2.39 '@vue/devtools-api': 6.2.1 - '@vueuse/core': 9.1.1_vue@3.2.38 + '@vueuse/core': 9.1.1_vue@3.2.39 body-scroll-lock: 4.0.0-beta.0 shiki: 0.11.1 vite: 3.0.9 - vue: 3.2.38 + vue: 3.2.39 transitivePeerDependencies: - '@algolia/client-search' - '@types/react' @@ -18839,6 +18964,21 @@ packages: optional: true dependencies: vue: 3.2.38 + dev: true + + /vue-demi/0.12.5_vue@3.2.39: + resolution: {integrity: sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + peerDependencies: + '@vue/composition-api': ^1.0.0-rc.1 + vue: ^3.0.0-0 || ^2.6.0 + peerDependenciesMeta: + '@vue/composition-api': + optional: true + dependencies: + vue: 3.2.39 /vue-demi/0.13.11: resolution: {integrity: sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==} @@ -18866,6 +19006,21 @@ packages: optional: true dependencies: vue: 3.2.38 + dev: true + + /vue-demi/0.13.11_vue@3.2.39: + resolution: {integrity: sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + peerDependencies: + '@vue/composition-api': ^1.0.0-rc.1 + vue: ^3.0.0-0 || ^2.6.0 + peerDependenciesMeta: + '@vue/composition-api': + optional: true + dependencies: + vue: 3.2.39 /vue-eslint-parser/9.0.3_eslint@8.23.0: resolution: {integrity: sha512-yL+ZDb+9T0ELG4VIFo/2anAOz8SvBdlqEnQnvJ3M7Scq56DvtjY0VY88bByRZB0D4J0u8olBcfrXTVONXsh4og==} @@ -18924,6 +19079,16 @@ packages: '@vue/runtime-dom': 3.2.38 '@vue/server-renderer': 3.2.38_vue@3.2.38 '@vue/shared': 3.2.38 + dev: true + + /vue/3.2.39: + resolution: {integrity: sha512-tRkguhRTw9NmIPXhzk21YFBqXHT2t+6C6wPOgQ50fcFVWnPdetmRqbmySRHznrYjX2E47u0cGlKGcxKZJ38R/g==} + dependencies: + '@vue/compiler-dom': 3.2.39 + '@vue/compiler-sfc': 3.2.39 + '@vue/runtime-dom': 3.2.39 + '@vue/server-renderer': 3.2.39_vue@3.2.39 + '@vue/shared': 3.2.39 /w3c-hr-time/1.0.2: resolution: {integrity: sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==} diff --git a/test/benchmark/package.json b/test/benchmark/package.json index 9e0def28981a..ea8366575574 100644 --- a/test/benchmark/package.json +++ b/test/benchmark/package.json @@ -2,7 +2,7 @@ "name": "@vitest/benchmark", "private": true, "scripts": { - "test": "vitest bench", + "test": "node test.mjs", "testu": "vitest -u", "coverage": "vitest run --coverage" } diff --git a/test/benchmark/test.mjs b/test/benchmark/test.mjs new file mode 100644 index 000000000000..6e54e181c96e --- /dev/null +++ b/test/benchmark/test.mjs @@ -0,0 +1,18 @@ +import { readFile } from 'fs/promises' +import { startVitest } from 'vitest/node' + +const success = await startVitest('benchmark', ['base.bench', 'mode.bench'], { + run: true, + update: false, + outputFile: './bench.json', // TODO move outputFile to benchmark + benchmark: { + reporters: ['json'], + }, +}) + +const benchResult = await readFile('./bench.json', 'utf-8') + +if (benchResult.includes('skip')) + process.exit(1) + +process.exit(success ? 0 : 1) diff --git a/test/benchmark/test/mode.bench.ts b/test/benchmark/test/mode.bench.ts new file mode 100644 index 000000000000..23ea159e093f --- /dev/null +++ b/test/benchmark/test/mode.bench.ts @@ -0,0 +1,11 @@ +import { bench, describe } from 'vitest' + +describe.skip('skipped', () => { + bench('skipped', () => { + throw new Error('should be skipped') + }) +}) + +bench.skip('skipped', () => { + throw new Error('should be skipped') +})