From: Russ Cox Date: Tue, 15 Nov 2011 18:59:59 +0000 (-0500) Subject: encoding/json: make BenchmarkSkipValue more consistent X-Git-Tag: weekly.2011-11-18~45 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a6106eef379ef560016d0dcdbdd9c9c86b7cd39c;p=gostls13.git encoding/json: make BenchmarkSkipValue more consistent Move scanner allocation out of loop. It's the only allocation in the test so it dominates when it triggers a garbage collection. R=golang-dev, r CC=golang-dev https://golang.org/cl/5369117 --- diff --git a/src/pkg/encoding/json/scanner_test.go b/src/pkg/encoding/json/scanner_test.go index a0a5995af8..14d850865a 100644 --- a/src/pkg/encoding/json/scanner_test.go +++ b/src/pkg/encoding/json/scanner_test.go @@ -186,11 +186,12 @@ func TestNextValueBig(t *testing.T) { } } +var benchScan scanner + func BenchmarkSkipValue(b *testing.B) { initBig() - var scan scanner for i := 0; i < b.N; i++ { - nextValue(jsonBig, &scan) + nextValue(jsonBig, &benchScan) } b.SetBytes(int64(len(jsonBig))) }