Logo

Schema Benchmarks

Collapse
    • homeHome

    • timerInitialization
    • check_circleValidation
    • output_circleParsing

    • download_2Download
Expand sidebar
Benchmarkschevron_rightParsing

Parsing a value to match the schema. This is different to validation because it returns a new value.

import * as v from "valibot";
import { personSchema } from "./schemas";

const person = v.parse(personSchema, data);
// person is of type Person
Data
check_circleValiderrorInvalid
Optimizations
flash_offNonecodeJITbuildPrecompiled
Abort early
errorAll errorswarningAbort early
LibraryVersionOptimizationsError typeMeanCompare
valibot (abortPipeEarly only)
Code snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.1.0NoneAbort early12 μs
valibot
Code snippet
v.safeParse(schema, data, { abortEarly: true })
1.1.0NoneAbort early12 μs
1x
stat_minus_1
effect
Code snippet
// const decodeFirst = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "first" }
// );
decodeFirst(data)

(Commented code is not benchmarked)

3.19.3NoneAbort early18 μs
1.5x
stat_minus_1
joi
Code snippet
schema.validate(data, { abortEarly: true })
18.0.1NoneAbort early36 μs
2.98x
stat_minus_1
yup
Code snippet
schema.validateSync(data, { abortEarly: true })
1.7.1NoneAbort early143 μs
11.71x
stat_minus_3
Created by eskimojo for Open Circle