Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Commit

Permalink
chore: add benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Dec 11, 2019
1 parent 1b120bd commit d893894
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions benchmarks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { validate, t } from '../validator'
import { Suite } from 'benchmark'
const suite = new Suite()

suite
.add('Validate | cache', {
defer: true,
fn (deferred) {
validate({ username: 'virk' }, t.schema({ username: t.string() }), {}, {
cacheKey: 'foo',
})
.then(() => {
deferred.resolve()
})
},
})
.add('Validate | no cache', {
defer: true,
fn (deferred) {
validate({ username: 'virk' }, t.schema({ username: t.string() }))
.then(() => {
deferred.resolve()
})
},
})
.on('cycle', function (event) {
console.log(String(event.target))
})
.on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').map('name'))
})
.run({ 'async': true })
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"devDependencies": {
"@adonisjs/mrm-preset": "^2.2.2",
"@types/node": "^12.12.16",
"benchmark": "^2.1.4",
"commitizen": "^4.0.3",
"cz-conventional-changelog": "^3.0.2",
"del-cli": "^3.0.0",
Expand Down

0 comments on commit d893894

Please sign in to comment.