Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove a property lookup during validation #28

Merged
merged 1 commit into from
Jan 25, 2017

Conversation

talyssonoc
Copy link
Owner

This PR makes the process of validation faster removing the lookup for the structure schema.

Here's how the validation benchmark was before the change (I ran it thrice due to possible variations):

> node benchmark/benchmark.js

# Validation:
With simple validation and is valid x 8,340 ops/sec ±2.08% (79 runs sampled)
With simple validation and is invalid x 4,573 ops/sec ±1.74% (81 runs sampled)
With nested validation and is valid x 5,687 ops/sec ±2.21% (79 runs sampled)
With nested validation and is invalid x 3,717 ops/sec ±2.07% (81 runs sampled)

=========

> node benchmark/benchmark.js

# Validation:
With simple validation and is valid x 8,596 ops/sec ±1.71% (83 runs sampled)
With simple validation and is invalid x 4,566 ops/sec ±1.94% (78 runs sampled)
With nested validation and is valid x 5,781 ops/sec ±1.77% (82 runs sampled)
With nested validation and is invalid x 3,735 ops/sec ±2.02% (79 runs sampled)

=========

> node benchmark/benchmark.js

# Validation:
With simple validation and is valid x 8,585 ops/sec ±1.67% (78 runs sampled)
With simple validation and is invalid x 4,565 ops/sec ±2.12% (80 runs sampled)
With nested validation and is valid x 5,784 ops/sec ±1.90% (82 runs sampled)
With nested validation and is invalid x 3,449 ops/sec ±3.12% (78 runs sampled)

And now after the change:

> node benchmark/benchmark.js

# Validation:
With simple validation and is valid x 8,816 ops/sec ±2.29% (80 runs sampled)
With simple validation and is invalid x 4,736 ops/sec ±5.27% (81 runs sampled)
With nested validation and is valid x 6,021 ops/sec ±1.87% (82 runs sampled)
With nested validation and is invalid x 4,002 ops/sec ±2.12% (82 runs sampled)

=========

> node benchmark/benchmark.js

# Validation:
With simple validation and is valid x 9,118 ops/sec ±2.11% (81 runs sampled)
With simple validation and is invalid x 4,947 ops/sec ±2.48% (81 runs sampled)
With nested validation and is valid x 5,923 ops/sec ±2.63% (80 runs sampled)
With nested validation and is invalid x 4,015 ops/sec ±2.09% (81 runs sampled)

=========

> node benchmark/benchmark.js

# Validation:
With simple validation and is valid x 8,593 ops/sec ±3.45% (77 runs sampled)
With simple validation and is invalid x 4,235 ops/sec ±5.33% (76 runs sampled)
With nested validation and is valid x 5,567 ops/sec ±2.25% (78 runs sampled)
With nested validation and is invalid x 3,547 ops/sec ±3.37% (76 runs sampled)

For most of the cases there were some improvement, I think it's worth it.

@fernandofleury fernandofleury merged commit 21ba682 into master Jan 25, 2017
@fernandofleury fernandofleury deleted the make-validation-faster branch January 25, 2017 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants