bytedance / go-tagexpr

An interesting go struct tag expression syntax for field validation, etc.
Apache License 2.0
1.66k stars 142 forks source link

feat: improve performance of type cache #44

Closed Leo-stone-dot closed 2 years ago

Leo-stone-dot commented 2 years ago

借鉴 sonic 对结构体信息缓存的方法,提升对结构体解析的性能,以下时在并发情况下的测试

goos: darwin
goarch: amd64
pkg: github.com/bytedance/go-tagexpr/v2/binding/gjson
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkGetFiledInfo-12               704923858                 1.79 ns/op
BenchmarkGetFieldInfoByMap-12           31975237                36.87 ns/op

goos: linux
goarch: amd64
pkg: github.com/bytedance/go-tagexpr/v2/binding/gjson
cpu: Intel(R) Xeon(R) Platinum 8260 CPU @ 2.40GHz
BenchmarkGetFiledInfo-8        575396450               2.42 ns/op
BenchmarkGetFieldInfoByMap-8    23272125              63.71 ns/op