Skip to main content
Version: 0.1.2

Benchmark Results

Generated: 2025-12-20 18:39:52 UTC

Library Notes

Feature Comparison

FeaturePedantigoPlaygroundOzzoHumaGodanticGodasse
Declarative constraints✅ tags✅ tags✅ rules✅ tags✅ methods❌ hand-written
JSON Schema generation
Default values
Unmarshal + validate
Validate existing struct❌*

*Godasse requires hand-written Validate() methods

Library Descriptions

  1. Pedantigo - Struct tag-based validation (validate:"required,email,min=5"). JSON Schema generation with caching.

  2. Playground (go-playground/validator) - Struct tag-based validation. Rich constraint library, no JSON Schema.

  3. Ozzo (ozzo-validation) - Rule builder API (validation.Field(&u.Name, validation.Required, validation.Length(2,100))). No struct tags.

  4. Huma - OpenAPI-focused. Validates map[string]any against schemas, not structs directly.

  5. Godantic - Method-based constraints (FieldName() FieldOptions[T]). JSON Schema, defaults, streaming partial JSON.

  6. Godasse - Deserializer with default: tag. All constraint validation requires hand-written Validate() methods.


Marshal

Validate + JSON marshal

StructPedantigoPlaygroundOzzoHumaGodanticGodasse
Simple1.88 µs (11 allocs)2.69 µs (9 allocs)unsupportedunsupportedunsupportedunsupported

New

Validator creation overhead

StructPedantigoPlaygroundOzzoHumaGodanticGodasse
Simple11.87 µs (110 allocs)16.05 µs (187 allocs)unsupported30.05 µs (255 allocs)26.55 µs (305 allocs)6.67 µs (72 allocs)
Complex28.70 µs (270 allocs)unsupportedunsupported73.61 µs (515 allocs)7.49 µs (75 allocs)23.32 µs (243 allocs)

OpenAPI

OpenAPI-compatible schema generation

StructPedantigoPlaygroundOzzoHumaGodanticGodasse
Uncached23.46 µs (204 allocs)unsupportedunsupported30.30 µs (255 allocs)unsupportedunsupported
Cached18 ns (0 allocs)unsupportedunsupported645 ns (6 allocs)unsupportedunsupported

Schema

JSON Schema generation

StructPedantigoPlaygroundOzzoHumaGodanticGodasse
Uncached22.74 µs (202 allocs)unsupportedunsupported30.18 µs (255 allocs)unsupportedunsupported
Cached18 ns (0 allocs)unsupportedunsupported638 ns (6 allocs)unsupportedunsupported

UnmarshalDirect

json.Unmarshal + Validate (no intermediate map)

StructPedantigoPlaygroundOzzoHumaGodanticGodasse
Simple3.45 µs (19 allocs)4.26 µs (16 allocs)unsupportedunsupportedunsupportedunsupported
Complex9.89 µs (39 allocs)11.07 µs (33 allocs)unsupportedunsupportedunsupportedunsupported

UnmarshalMap

JSON → map → validate (Pedantigo validates and outputs struct, Huma only validates the map)

StructPedantigoPlaygroundOzzoHumaGodanticGodasse
Simple4.99 µs (39 allocs)unsupportedunsupported3.55 µs (26 allocs)unsupported5.43 µs (46 allocs)
Complex18.23 µs (135 allocs)unsupportedunsupported10.36 µs (78 allocs)unsupported17.28 µs (153 allocs)

Validate

Validate existing struct (no JSON parsing)

StructPedantigoPlaygroundOzzoHumaGodanticGodasse
Simple1.43 µs (10 allocs)2.16 µs (7 allocs)12.81 µs (43 allocs)unsupported6.03 µs (48 allocs)unsupported
Complex2.26 µs (15 allocs)3.43 µs (9 allocs)12.31 µs (139 allocs)unsupported13.87 µs (120 allocs)unsupported
Large1.60 µs (22 allocs)1.85 µs (3 allocs)46.97 µs (254 allocs)unsupported14.79 µs (126 allocs)unsupported

Summary

Validate_Simple (struct validation)

Libraryns/opallocsvs Pedantigo
Pedantigo1.43 µs10baseline
Playground2.16 µs71.51x slower
Ozzo12.81 µs438.94x slower
Huma---
Godantic6.03 µs484.21x slower
Godasse---

Validate_Complex (nested structs)

Libraryns/opallocsvs Pedantigo
Pedantigo2.26 µs15baseline
Playground3.43 µs91.52x slower
Ozzo12.31 µs1395.45x slower
Huma---
Godantic13.87 µs1206.15x slower
Godasse---

UnmarshalMap_Simple (JSON → struct + validate)

Libraryns/opallocsvs Pedantigo
Pedantigo4.99 µs39baseline
Playground---
Ozzo---
Huma3.55 µs261.40x faster
Godantic---
Godasse5.43 µs461.09x slower

UnmarshalMap_Complex (nested JSON)

Libraryns/opallocsvs Pedantigo
Pedantigo18.23 µs135baseline
Playground---
Ozzo---
Huma10.36 µs781.76x faster
Godantic---
Godasse17.28 µs1531.05x faster

Schema_Uncached (first-time generation)

Libraryns/opallocsvs Pedantigo
Pedantigo22.74 µs202baseline
Playground---
Ozzo---
Huma30.18 µs2551.33x slower
Godantic---
Godasse---

Schema_Cached (cached lookup)

Libraryns/opallocsvs Pedantigo
Pedantigo18 ns0baseline
Playground---
Ozzo---
Huma638 ns634.87x slower
Godantic---
Godasse---

Generated by pedantigo-benchmarks

Benchmark naming convention
Benchmark_<Library>_<Feature>_<Struct>

Libraries: Pedantigo, Playground, Ozzo, Huma, Godantic, Godasse
Features: Validate, UnmarshalMap, UnmarshalDirect, New, Schema, OpenAPI, Marshal
Structs: Simple (5 fields), Complex (nested), Large (20+ fields)