]> Cypherpunks repositories - gostls13.git/commit
encoding/json: use sync.Pool
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 18 Dec 2013 23:52:05 +0000 (15:52 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 18 Dec 2013 23:52:05 +0000 (15:52 -0800)
commit46b4ed2cf065a9877257c6641e40a0e3cd1468fd
tree607c9284a4333f790cbb6a4427d4fa117699cdac
parent3f6dbfc44ca7b5ed6e01f82b8833e626227320d9
encoding/json: use sync.Pool

Benchmark is within the noise. I had to run this a dozen times
each before & after (on wall power, without a browser running)
before I could get halfway consistent numbers, and even then
they jumped all over the place, with the new one sometimes
being better. But these are the best of a dozen each.

Slowdown is expected anyway, since I imagine channels are
optimized more.

benchmark                 old ns/op    new ns/op    delta
BenchmarkCodeEncoder       26556987     27291072   +2.76%
BenchmarkEncoderEncode         1069         1071   +0.19%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkCodeEncoder          73.07        71.10    0.97x

benchmark                old allocs   new allocs    delta
BenchmarkEncoderEncode            2            2    0.00%

benchmark                 old bytes    new bytes    delta
BenchmarkEncoderEncode          221          221    0.00%

Update #4720

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/37720047
src/pkg/encoding/json/encode.go
src/pkg/encoding/json/stream.go