aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2019-04-05 22:28:31 +0200
committerDaniel Martí <mvdan@mvdan.cc>2019-04-05 20:54:50 +0000
commitcb6646234cb6565d19d9efea987c8d8fc9be5c31 (patch)
treebdfb2f3e2e38b12fc82d13aeb700ea7245083439 /src/encoding
parent06cff114cf786d5f901aa41ac873f9e8bb8e1eba (diff)
downloadgo-cb6646234cb6565d19d9efea987c8d8fc9be5c31.tar.xz
encoding/json: use SetBytes in UnmarshalReuse benchmark
This was the only benchmark missing the SetBytes call, as spotted earlier by Bryan. It's not required to make the benchmark useful, but it can still be a good way to see how its speed is affected by the reduced allocations: name time/op CodeUnmarshal-8 12.1ms ± 1% CodeUnmarshalReuse-8 11.4ms ± 1% name speed CodeUnmarshal-8 161MB/s ± 1% CodeUnmarshalReuse-8 171MB/s ± 1% name alloc/op CodeUnmarshal-8 3.28MB ± 0% CodeUnmarshalReuse-8 1.94MB ± 0% name allocs/op CodeUnmarshal-8 92.7k ± 0% CodeUnmarshalReuse-8 77.6k ± 0% While at it, remove some unnecessary empty lines. Change-Id: Ib2bd92d5b3237b8f3092e8c6f863dab548fee2f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/170938 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/encoding')
-rw-r--r--src/encoding/json/bench_test.go2
-rw-r--r--src/encoding/json/example_test.go1
-rw-r--r--src/encoding/json/stream_test.go2
3 files changed, 1 insertions, 4 deletions
diff --git a/src/encoding/json/bench_test.go b/src/encoding/json/bench_test.go
index c81ab8e993..f2592e3dbd 100644
--- a/src/encoding/json/bench_test.go
+++ b/src/encoding/json/bench_test.go
@@ -242,7 +242,7 @@ func BenchmarkCodeUnmarshalReuse(b *testing.B) {
}
}
})
- // TODO(bcmills): Is there a missing b.SetBytes here?
+ b.SetBytes(int64(len(codeJSON)))
}
func BenchmarkUnmarshalString(b *testing.B) {
diff --git a/src/encoding/json/example_test.go b/src/encoding/json/example_test.go
index 4c075ddaa6..2088c34297 100644
--- a/src/encoding/json/example_test.go
+++ b/src/encoding/json/example_test.go
@@ -170,7 +170,6 @@ func ExampleDecoder_Decode_stream() {
// Sam: Go fmt who?
// Ed: Go fmt yourself!
// json.Delim: ]
-
}
// This example uses RawMessage to delay parsing part of a JSON message.
diff --git a/src/encoding/json/stream_test.go b/src/encoding/json/stream_test.go
index 8dc74e5466..1d1999da25 100644
--- a/src/encoding/json/stream_test.go
+++ b/src/encoding/json/stream_test.go
@@ -368,7 +368,6 @@ var tokenStreamCases = []tokenStreamCase{
}
func TestDecodeInStream(t *testing.T) {
-
for ci, tcase := range tokenStreamCases {
dec := NewDecoder(strings.NewReader(tcase.json))
@@ -401,7 +400,6 @@ func TestDecodeInStream(t *testing.T) {
}
}
}
-
}
// Test from golang.org/issue/11893