aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2023-04-01 18:44:20 +0100
committerDaniel Martí <mvdan@mvdan.cc>2023-04-04 07:16:59 +0000
commit56e900d9f0da967d9152c546db1684653a69ece5 (patch)
treeb38bc9803d1ad01d90809055c4cbc8407c574126 /src/encoding
parent311145cf0d0c9e80efb23b959f58bfa33d7f4c88 (diff)
downloadgo-56e900d9f0da967d9152c546db1684653a69ece5.tar.xz
encoding/gob: report allocs in benchmarks
I almost exclusively use these benchmarks with -benchtime already. Change-Id: I6539cbba6abbdb6b275502e122f4e16856d8b9e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/481375 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/encoding')
-rw-r--r--src/encoding/gob/timing_test.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/encoding/gob/timing_test.go b/src/encoding/gob/timing_test.go
index bdee39c447..84349fb179 100644
--- a/src/encoding/gob/timing_test.go
+++ b/src/encoding/gob/timing_test.go
@@ -21,6 +21,7 @@ type Bench struct {
}
func benchmarkEndToEnd(b *testing.B, ctor func() any, pipe func() (r io.Reader, w io.Writer, err error)) {
+ b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) {
r, w, err := pipe()
if err != nil {
@@ -135,6 +136,7 @@ func TestCountDecodeMallocs(t *testing.T) {
func benchmarkEncodeSlice(b *testing.B, a any) {
b.ResetTimer()
+ b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) {
var buf bytes.Buffer
enc := NewEncoder(&buf)
@@ -229,6 +231,7 @@ func benchmarkDecodeSlice(b *testing.B, a any) {
rt := ra.Type()
b.ResetTimer()
+ b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) {
// TODO(#19025): Move per-thread allocation before ResetTimer.
rp := reflect.New(rt)
@@ -316,6 +319,7 @@ func BenchmarkDecodeMap(b *testing.B) {
}
bbuf := benchmarkBuf{data: buf.Bytes()}
b.ResetTimer()
+ b.ReportAllocs()
for i := 0; i < b.N; i++ {
var rm map[int]int
bbuf.reset()