1
0
mirror of https://github.com/golang/go synced 2024-10-03 00:21:22 -06:00

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
This commit is contained in:
Russ Cox 2011-11-15 13:59:59 -05:00
parent cb85e8ac27
commit a6106eef37

View File

@ -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)))
}