Benchmarks and compatibility checks that compare ValidGen with go-playground/validator.
These tests live in this module so github.com/opencodeco/validgen does not require github.com/go-playground/validator/v10.
- Git
- Go >= 1.24
- Make
bench times one struct three ways: ValidGen, go-playground/validator, and handwritten checks.
make benchmake bench runs the ValidGen CLI on ./bench, then:
go test -bench=. -benchmem -benchtime=5s ./benchcmp times ValidGen and go-playground/validator for the validations and types TestGen emits.
make cmpThe default bench time is 5 seconds per benchmark. This suite has hundreds of benchmarks. Set a shorter time for a local check:
make cmp BENCH_TIME=100mscolor checks that ValidGen's hex, rgb, rgba, hsl, and hsla helpers accept the same strings as go-playground/validator v10.28.0.
make colorFrom a ValidGen checkout, point TestGen at this repository and generate the comparative cases:
export VALIDGEN_BENCHMARKS_DIR=/absolute/path/to/validgen-benchmarks
make testgenThat rewrites cmp/generated_cmp_perf_no_pointer_test.go and cmp/generated_cmp_perf_pointer_test.go from the templates in cmp/.
Then regenerate the ValidGen functions in this repository:
make regenmake regen runs go tool validgen on bench and cmp. Commit the generated Go files with the template output.
MIT. See LICENSE.