Benchmarks
For ObjectParser, I've written a simple benchmark engine for node.js and the browser.
It works like this: the script connects all available packages, test groups and tests, then runs all the loaded tests one by one and saves their results. After, finds the average value of each test.
The result is the number of iterations per millisecond. The larger it is, the faster the script runs.
Warning!
I tried to reduce the possibility of optimizing the launch of each test by JavaScript engine. Each test will be run in turn, and after running the last test, we return to the beginning and repeat. In theory, this launch option will not allow the engine to cache the execution of one test, and then repeat it for the next 10,000 iterations (or how many there will be).
Results for Node.js
Existence validator 10,000 repeats
- ✓ ObjectParser with raw array schema 2 iterations per 1 ms
- ✓ ObjectParser with raw schema 2 iterations per 1 ms
- ✓ ObjectParser with schema 15 iterations per 1 ms
- ✓ Validate.js 7 iterations per 1 ms
Existence validator of nested object 10,000 repeats
- ✓ ObjectParser with schema 12 iterations per 1 ms
- ✓ Validate.js 38 iterations per 1 ms
Type validator 10,000 repeats
- ✓ ObjectParser 54 iterations per 1 ms
- ✓ Validate.js 15 iterations per 1 ms
Default setter 10,000 repeats
- ✓ ObjectParser set primitive value 32 iterations per 1 ms
- ✓ ObjectParser set no primitive value 35 iterations per 1 ms
Custom validator 10,000 repeats
- ✓ ObjectParser 30 iterations per 1 ms
- ✓ Validate.js 21 iterations per 1 ms
Clone object 10,000 repeats
- ✓ ObjectParser 15 iterations per 1 ms