typescript-runtime-type-benchmarks icon indicating copy to clipboard operation
typescript-runtime-type-benchmarks copied to clipboard

Benchmark schema compilation time

Open ottomated opened this issue 9 months ago • 2 comments

In an serverless environment like a Cloudflare worker, schemas may need to be created on every request. This benchmark doesn't take that into account.

I propose adding a new suite that would look something like this. It would need to be somewhat of a complicated schema to measure factors such as string parsing:

createCase('arktype', 'compileSchema', () => {
  return () =>
    type({
      string: 'string',
      stringRange: '0 < string <= 10',
      'optional?': 'number[]',
    });
});

createCase('zod', 'compileSchema', () => {
  return () =>
    z.object({
      string: z.string(),
      stringRange: z.string().min(0).max(10),
      optional: z.array(z.number()).optional(),
    });
});

ottomated avatar Feb 09 '25 05:02 ottomated

Serverless thing should be aoted really Like typia

kravetsone avatar Feb 19 '25 17:02 kravetsone

Funny, but Zod v4 might be slower here https://github.com/DZakh/sury?comparison

DZakh avatar May 21 '25 08:05 DZakh