A lot of validation time is being spent in require. Though there is a require cache for the actual loading of the required file, the pathname still needs to be resolved and validated when requiring a relative path.
Caching the validator functions immediately gave me a 5-6x speedup on a small micro-benchmark I put together, but it will easily give bigger speedups with more complex objects.
before x 288 ops/sec ±2.35% (83 runs sampled)
after x 1,609 ops/sec ±2.30% (88 runs sampled)
A lot of validation time is being spent in
require
. Though there is a require cache for the actual loading of the required file, the pathname still needs to be resolved and validated when requiring a relative path.Caching the validator functions immediately gave me a 5-6x speedup on a small micro-benchmark I put together, but it will easily give bigger speedups with more complex objects.