Releases: Pungyeon/required
v0.6
v0.5
v0.4
v0.3
Here are the benchmarks from v0.2:
goos: darwin
goarch: amd64
pkg: github.com/Pungyeon/required/pkg/json
BenchmarkStdUnmarshal-8 148515 7747 ns/op 1344 B/op 26 allocs/op
BenchmarkPkgUnmarshal-8 57804 20503 ns/op 17037 B/op 267 allocs/op
PASS
ok github.com/Pungyeon/required/pkg/json 3.077s
The highlights being ~x3 worse performance than the std library marshaler and more than x10 the memory consumption (and memory allocations). Even though the code was quite nice, the performance was unfortunately horrendous. After the optimisations of this pull request, we see the following results:
goos: darwin
goarch: amd64
pkg: github.com/Pungyeon/required/pkg/json
BenchmarkStdUnmarshal-8 149682 7784 ns/op 1344 B/op 26 allocs/op
BenchmarkPkgUnmarshal-8 155384 7684 ns/op 1512 B/op 34 allocs/op
PASS
ok github.com/Pungyeon/required/pkg/json 2.941s
These results are much more convincing. I have tried my best to find the last 8 allocations and get rid of them, but it seems that the approach is just different. Either way, it looks like they are quite even in speed, as well as memory consumption. This is great 🎉
There are also a few bugs which have been fixed, such as:
- Support of custom json marshaling (by extending the std lib json.Unmarshaler interface)....
- Private fields are ignored (rather than causing a panic)
- Pointers and Interface types are now parsed in a much nicer manner
- There is no longer any string -> []byte conversion in the Unmarshalling of the json, making this a lot closer to std library functionality.
- Support of
uint
types
Unfortunately, this performance optimisation has made the code quality suffer quite significantly 😬 However, it's still more understandable than the code in the std library 😅 So I'll let it pass for now.