LogoLogo

Schema Benchmarks

    • home
      Home

    • download_2
      Download

    • timer
      Initialization
    • check_circle
      Validation
    • output_circle
      Parsing
    • swap_horiz
      Codec
    • schema
      Standard Schema
    • format_quote
      String

    • error
      Stack

    • deployed_code
      Libraries

    • article
      Blog
Expand sidebarExpand sidebar
Benchmarks/CodecCodec
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences

Some schema libraries support two way conversion of data, often referred to as "encoding" and "decoding".

We benchmark the time taken to encode and decode a bigint to and from a string.

Copy to clipboardCopy to clipboard
import * as z from "zod"; const bigIntFromString = z.codec(z.bigint(), z.string(), { encode: (bigint) => bigint.toString(), decode: (str) => BigInt(str), }); bigIntFromString.encode(1234567890123456789n); // "1234567890123456789" bigIntFromString.decode("1234567890123456789"); // 1234567890123456789n
format_quoteInvalid data

We don't benchmark codecs with invalid data, as many libraries require the input to be correctly typed before passing it to the codec.

Optimizations
flash_offNonecodeJITbuildPrecompiled
LibrarysortVersionDownloads (/wk)sortOptimizationsEncodearrow_upwardDecodesort
typebox
Accepts unknown valuesAccepts unknown values
This codec allows unknown input, requiring extra validation.
1.3.66.2MJIT
Code snippetCode snippet
// const BigIntFromString = Type.Codec(...).Decode(...).Encode(...);
Value.Encode(BigIntFromString, data)

(Commented code is not benchmarked)

4 μs
Code snippetCode snippet
// const BigIntFromString = Type.Codec(...).Decode(...).Encode(...);
Value.Decode(BigIntFromString, data)

(Commented code is not benchmarked)

4 μs
effect@beta (unknown)
Accepts unknown valuesAccepts unknown values
This codec allows unknown input, requiring extra validation.
4.0.0-beta.9824.01MNone
Code snippetCode snippet
// const BigIntFromString = Schema.BigIntFromString;
Schema.encodeUnknownSync(BigIntFromString)(data)

(Commented code is not benchmarked)

2 μs
Code snippetCode snippet
// const BigIntFromString = Schema.BigIntFromString;
Schema.decodeUnknownSync(BigIntFromString)(data)

(Commented code is not benchmarked)

2 μs
effect@beta4.0.0-beta.9824.01MNone
Code snippetCode snippet
// const BigIntFromString = Schema.BigIntFromString;
Schema.encodeSync(BigIntFromString)(data)

(Commented code is not benchmarked)

2 μs
Code snippetCode snippet
// const BigIntFromString = Schema.BigIntFromString;
Schema.decodeSync(BigIntFromString)(data)

(Commented code is not benchmarked)

2 μs
effect (unknown)
Accepts unknown valuesAccepts unknown values
This codec allows unknown input, requiring extra validation.
3.22.024.01MNone
Code snippetCode snippet
Schema.encodeUnknownSync(Schema.BigInt)(data)
378 ns
Code snippetCode snippet
Schema.decodeUnknownSync(Schema.BigInt)(data)
439 ns
effect3.22.024.01MNone
Code snippetCode snippet
Schema.encodeSync(Schema.BigInt)(data)
365 ns
Code snippetCode snippet
Schema.decodeSync(Schema.BigInt)(data)
437 ns
zod4.4.3245.4MJIT
Code snippetCode snippet
z.codec(...).encode(data)
170 ns
Code snippetCode snippet
z.codec(...).decode(data)
208 ns
zod/mini4.4.3245.4MJIT
Code snippetCode snippet
z.encode(codec, data)
166 ns
Code snippetCode snippet
z.decode(codec, data)
205 ns
sury11.0.0-alpha.10297.33KJIT
Code snippetCode snippet
// const encoder = S.encoder(S.bigint, S.string);
encoder(data)

(Commented code is not benchmarked)

82 ns
Code snippetCode snippet
// const decoder = S.decoder(S.string, S.bigint);
decoder(data)

(Commented code is not benchmarked)

119 ns
io-ts2.2.222.69MNone
Code snippetCode snippet
// const BigIntFromString = new t.Type<bigint, string, string>(...)
BigIntFromString.encode(data)

(Commented code is not benchmarked)

82 ns
Code snippetCode snippet
// const BigIntFromString = new t.Type<bigint, string, string>(...)
BigIntFromString.decode(data)

(Commented code is not benchmarked)

131 ns
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures