mirror of https://github.com/golang/go.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
This commit is contained in:
parent
cb85e8ac27
commit
a6106eef37
|
|
@ -186,11 +186,12 @@ func TestNextValueBig(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var benchScan scanner
|
||||||
|
|
||||||
func BenchmarkSkipValue(b *testing.B) {
|
func BenchmarkSkipValue(b *testing.B) {
|
||||||
initBig()
|
initBig()
|
||||||
var scan scanner
|
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
nextValue(jsonBig, &scan)
|
nextValue(jsonBig, &benchScan)
|
||||||
}
|
}
|
||||||
b.SetBytes(int64(len(jsonBig)))
|
b.SetBytes(int64(len(jsonBig)))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue