diff options
| author | Phil Pearl <philip.j.r.pearl@gmail.com> | 2019-10-13 13:01:58 +0100 |
|---|---|---|
| committer | Daniel Martí <mvdan@mvdan.cc> | 2019-10-27 16:02:29 +0000 |
| commit | 22d377077c01ced185f5f8d27f608e8c6dcb473c (patch) | |
| tree | 6e2a7c6470f2991ee2a54dded0dcb165bbf8217a /src/encoding/json/encode.go | |
| parent | 31bfab4ac621e81100d7fc3bc8cf483c5d2d2fef (diff) | |
| download | go-22d377077c01ced185f5f8d27f608e8c6dcb473c.tar.xz | |
encoding/json: improve performance of Compact
This change improves performance of Compact by using a sync.Pool to allow re-use
of a scanner. This also has the side-effect of removing an allocation for each
field that implements Marshaler when marshalling JSON.
name old time/op new time/op delta
EncodeMarshaler-8 118ns ± 2% 104ns ± 1% -12.21% (p=0.001 n=7+7)
name old alloc/op new alloc/op delta
EncodeMarshaler-8 100B ± 0% 36B ± 0% -64.00% (p=0.000 n=8+8)
name old allocs/op new allocs/op delta
EncodeMarshaler-8 3.00 ± 0% 2.00 ± 0% -33.33% (p=0.000 n=8+8)
Change-Id: Ic70c61a0a6354823da5220f5aad04b94c054f233
Reviewed-on: https://go-review.googlesource.com/c/go/+/200864
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/encoding/json/encode.go')
0 files changed, 0 insertions, 0 deletions
