Skip to content

Address misleading performance benchmarks #1303

@ottomated

Description

@ottomated

I was looking into migrating from Zod and was drawn by the validation benchmarks on both the homepage and blog post. My intuition, however, was that the expensive schema initialization step would make arktype a mistake for serverless environments such as Cloudflare workers where schemas are reinitialized on each request.

I verified it with a quick benchmark that shows a significant performance hit that unfortunately more than outweighs the gain on validation speed:

Image

import { run, bench, boxplot, summary } from 'mitata';
import { z } from 'zod';
import { type } from 'arktype';

boxplot(() => {
  summary(() => {
    bench('zod', () => z.object({
      string: z.string(),
      stringRange: z.string().min(0).max(10),
      optional: z.array(z.number()).optional(),
    }));
    bench('arktype', () => type({
      string: 'string',
      stringRange: '0 < string <= 10',
      'optional?': 'number[]',
    }));
  });
});

await run();

I understand that the library is not focused on initialization performance, but it feels a bit misleading to advertise a 100x speedup when a significant portion of your users will actually experience the opposite. Would it be possible to add a note mentioning this to the relevant docs pages?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done (merged or closed)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions