aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/encoding/json/bench_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/encoding/json/bench_test.go')
-rw-r--r--libgo/go/encoding/json/bench_test.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/libgo/go/encoding/json/bench_test.go b/libgo/go/encoding/json/bench_test.go
index 72cb349..f2592e3 100644
--- a/libgo/go/encoding/json/bench_test.go
+++ b/libgo/go/encoding/json/bench_test.go
@@ -82,6 +82,7 @@ func codeInit() {
}
func BenchmarkCodeEncoder(b *testing.B) {
+ b.ReportAllocs()
if codeJSON == nil {
b.StopTimer()
codeInit()
@@ -99,6 +100,7 @@ func BenchmarkCodeEncoder(b *testing.B) {
}
func BenchmarkCodeMarshal(b *testing.B) {
+ b.ReportAllocs()
if codeJSON == nil {
b.StopTimer()
codeInit()
@@ -133,6 +135,7 @@ func benchMarshalBytes(n int) func(*testing.B) {
}
func BenchmarkMarshalBytes(b *testing.B) {
+ b.ReportAllocs()
// 32 fits within encodeState.scratch.
b.Run("32", benchMarshalBytes(32))
// 256 doesn't fit in encodeState.scratch, but is small enough to
@@ -143,6 +146,7 @@ func BenchmarkMarshalBytes(b *testing.B) {
}
func BenchmarkCodeDecoder(b *testing.B) {
+ b.ReportAllocs()
if codeJSON == nil {
b.StopTimer()
codeInit()
@@ -167,6 +171,7 @@ func BenchmarkCodeDecoder(b *testing.B) {
}
func BenchmarkUnicodeDecoder(b *testing.B) {
+ b.ReportAllocs()
j := []byte(`"\uD83D\uDE01"`)
b.SetBytes(int64(len(j)))
r := bytes.NewReader(j)
@@ -182,6 +187,7 @@ func BenchmarkUnicodeDecoder(b *testing.B) {
}
func BenchmarkDecoderStream(b *testing.B) {
+ b.ReportAllocs()
b.StopTimer()
var buf bytes.Buffer
dec := NewDecoder(&buf)
@@ -204,6 +210,7 @@ func BenchmarkDecoderStream(b *testing.B) {
}
func BenchmarkCodeUnmarshal(b *testing.B) {
+ b.ReportAllocs()
if codeJSON == nil {
b.StopTimer()
codeInit()
@@ -221,6 +228,7 @@ func BenchmarkCodeUnmarshal(b *testing.B) {
}
func BenchmarkCodeUnmarshalReuse(b *testing.B) {
+ b.ReportAllocs()
if codeJSON == nil {
b.StopTimer()
codeInit()
@@ -234,10 +242,11 @@ func BenchmarkCodeUnmarshalReuse(b *testing.B) {
}
}
})
- // TODO(bcmills): Is there a missing b.SetBytes here?
+ b.SetBytes(int64(len(codeJSON)))
}
func BenchmarkUnmarshalString(b *testing.B) {
+ b.ReportAllocs()
data := []byte(`"hello, world"`)
b.RunParallel(func(pb *testing.PB) {
var s string
@@ -250,6 +259,7 @@ func BenchmarkUnmarshalString(b *testing.B) {
}
func BenchmarkUnmarshalFloat64(b *testing.B) {
+ b.ReportAllocs()
data := []byte(`3.14`)
b.RunParallel(func(pb *testing.PB) {
var f float64
@@ -262,6 +272,7 @@ func BenchmarkUnmarshalFloat64(b *testing.B) {
}
func BenchmarkUnmarshalInt64(b *testing.B) {
+ b.ReportAllocs()
data := []byte(`3`)
b.RunParallel(func(pb *testing.PB) {
var x int64
@@ -300,6 +311,7 @@ func BenchmarkUnmapped(b *testing.B) {
}
func BenchmarkTypeFieldsCache(b *testing.B) {
+ b.ReportAllocs()
var maxTypes int = 1e6
if testenv.Builder() != "" {
maxTypes = 1e3 // restrict cache sizes on builders