Skip to content

Commit

Permalink
docs: move benchmarks docs to its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jun 8, 2023
1 parent 9a5e64f commit 3130e7f
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 43 deletions.
50 changes: 7 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# @vinejs/vine

![](https://github.com/thetutlage/static/blob/main/sponsorkit/sponsors.png?raw=true)

<hr>
<br />

Expand All @@ -18,49 +16,9 @@

</div>

## Benchmarks
Following are results of the benchmarks performed between Yup, Zod and VineJS.

- **Machine**: Apple M1 - 16GB Ram
- **Node.js version**: v20.2.0
- **Running benchmarks**: You can run benchmarks on your computer by executing `npm run benchmark` script.

```
===============================
Benchmarking with flat object
===============================
Vine x 9,208,428 ops/sec ±0.99% (86 runs sampled)
Zod x 1,158,997 ops/sec ±0.89% (87 runs sampled)
Yup x 413,173 ops/sec ±0.59% (90 runs sampled)
Fastest is Vine
=================================
Benchmarking with nested object
=================================
Vine x 8,157,981 ops/sec ±0.34% (89 runs sampled)
Zod x 558,226 ops/sec ±0.38% (87 runs sampled)
Yup x 192,073 ops/sec ±1.19% (90 runs sampled)
Fastest is Vine
======================
Benchmarking arrays
======================
Vine x 6,816,681 ops/sec ±1.65% (90 runs sampled)
Zod x 420,825 ops/sec ±0.35% (91 runs sampled)
Yup x 119,343 ops/sec ±0.38% (91 runs sampled)
Fastest is Vine
=======================
Benchmarking unions
=======================
Vine x 8,791,274 ops/sec ±0.65% (85 runs sampled)
Zod x 184,658 ops/sec ±0.53% (85 runs sampled)
Fastest is Vine
```

<div align="center">
<h3>
<a href="https://vinejs.dev">
<a href="./benchmarks.md">
Benchmarks
</a>
<span> | </span>
Expand All @@ -78,6 +36,12 @@ Fastest is Vine
<sub>Built with ❤︎ by <a href="https://github.com/thetutlage">Harminder Virk</a>
</div>

<br />
<hr>
<br />

![](https://github.com/thetutlage/static/blob/main/sponsorkit/sponsors.png?raw=true)

[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/vinejs/vine/test.yml?style=for-the-badge
[gh-workflow-url]: https://github.com/vinejs/vine/actions/workflows/test.yml "Github action"

Expand Down
83 changes: 83 additions & 0 deletions benchmarks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Benchmarks
Following are the results from the benchmarks executed on `Apple M1 Mac - 16GB`. Feel free to clone this repo and re-run the benchmarks on your local computer.

- We benchmark VineJS against only those validation libraries, that offers similar API for composing schema.
- Being slower does not mean bad. Continue using Yup or Zod if they work great for you, or if performance is not a bottleneck for you.
- VineJS performance is the outcome of our pre-compiling API. Both Yup and Zod has no option for pre-compiling schemas.

## Benchmarking against flat object
The source for this benchmark is saved inside the [./benchmarks/flat_object.ts](./benchmarks/flat_object.ts) file. You may run the benchmark as follows.

```sh
npm run build
node build/benchmarks/flat_object.js
```

### Results
```
===============================
Benchmarking with flat object
===============================
Vine x 9,208,428 ops/sec ±0.99% (86 runs sampled)
Zod x 1,158,997 ops/sec ±0.89% (87 runs sampled)
Yup x 413,173 ops/sec ±0.59% (90 runs sampled)
Fastest is Vine
```

## Benchmarking against nested object
The source for this benchmark is saved inside the [./benchmarks/nested_object.ts](./benchmarks/nested_object.ts) file. You may run the benchmark as follows.

```sh
npm run build
node build/benchmarks/nested_object.js
```

### Results
```
=================================
Benchmarking with nested object
=================================
Vine x 8,157,981 ops/sec ±0.34% (89 runs sampled)
Zod x 558,226 ops/sec ±0.38% (87 runs sampled)
Yup x 192,073 ops/sec ±1.19% (90 runs sampled)
Fastest is Vine
```

## Benchmarking arrays
The source for this benchmark is saved inside the [./benchmarks/array.ts](./benchmarks/array.ts) file. You may run the benchmark as follows.

```sh
npm run build
node build/benchmarks/array.js
```

### Results
```
======================
Benchmarking arrays
======================
Vine x 6,816,681 ops/sec ±1.65% (90 runs sampled)
Zod x 420,825 ops/sec ±0.35% (91 runs sampled)
Yup x 119,343 ops/sec ±0.38% (91 runs sampled)
Fastest is Vine
```

## Benchmarking unions
The source for this benchmark is saved inside the [./benchmarks/union.ts](./benchmarks/union.ts) file. You may run the benchmark as follows.

> **Note**: Yup does not have support for unions and hence there are no benchmarks for it.
```sh
npm run build
node build/benchmarks/union.js
```

### Results
```
=======================
Benchmarking unions
=======================
Vine x 8,791,274 ops/sec ±0.65% (85 runs sampled)
Zod x 184,658 ops/sec ±0.53% (85 runs sampled)
Fastest is Vine
```

0 comments on commit 3130e7f

Please sign in to comment.