Performance comparison to Zod for piped string
Hello!
I'm looking to implement a validator in a pretty performance critical area - so have been comparing some of the data contracts used, and in each test thrown together, ArkType is easily faster.... apart from one where a string is piped through a couple of stages
The Zod equivilant is
const zodTest = z.string().trim().toLowerCase().email().startsWith("info");
And for ArkType I've got const arkTest = type("string.trim |> string.lower |> string.email & /^info/");
And running the tests of
zodTest.parse(" [email protected]")
arkTest(" [email protected]")
In this scenario, ArkType is about 10x slower. It's still very quick, so there's no concerns about anything; I'm just wondering if I'm missing a trick when writing the type that'd speed things up?
Thanks!
1 Reply
Not sure about any tips, but a small change I would do is checking the prefix before email. It looks like it would perform better.