▲ | seabass 2 days ago | ||||||||||||||||
I was surprised by the source including a bunch of try/catch, which results in deopts for that code path as far as I understand, given that the stated benefit over Zod and other validators was that this should be run in performance critical code. I’d be curious to see benchmarks that show whether this is faster than zod, valibot, and zod4 mini in hot code paths. | |||||||||||||||||
▲ | nayajunimesh 2 days ago | parent | next [-] | ||||||||||||||||
We do use try/catch in a few places. However, in normal operations (valid input), no exceptions are thrown - the try/catch blocks are present in certain validators but do not execute their catch clauses. AFAIK, modern engines generally don’t impose large steady-state penalties merely for the presence of a try/catch when no exception is thrown; the measurable cost is usually when exceptions are actually thrown. When an element/property fails, the catch is used to construct precise error paths. That’s intentionally trading some failure-path overhead for better developer diagnostics. In the new few days, I'll prepare benchmarks to compare with Zod and Valibot! | |||||||||||||||||
| |||||||||||||||||
▲ | CharlesW 2 days ago | parent | prev [-] | ||||||||||||||||
OP, you could potentially leverage an existing benchmark suite: https://naruaway.github.io/valibot-benchmarks/ | |||||||||||||||||
|