diff options
Diffstat (limited to 'libgo/go/gob/timing_test.go')
-rw-r--r-- | libgo/go/gob/timing_test.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libgo/go/gob/timing_test.go b/libgo/go/gob/timing_test.go index 645f4fe..2a2be73 100644 --- a/libgo/go/gob/timing_test.go +++ b/libgo/go/gob/timing_test.go @@ -53,6 +53,7 @@ func TestCountEncodeMallocs(t *testing.T) { var buf bytes.Buffer enc := NewEncoder(&buf) bench := &Bench{7, 3.2, "now is the time", []byte("for all good men")} + runtime.UpdateMemStats() mallocs := 0 - runtime.MemStats.Mallocs const count = 1000 for i := 0; i < count; i++ { @@ -61,6 +62,7 @@ func TestCountEncodeMallocs(t *testing.T) { t.Fatal("encode:", err) } } + runtime.UpdateMemStats() mallocs += runtime.MemStats.Mallocs fmt.Printf("mallocs per encode of type Bench: %d\n", mallocs/count) } @@ -77,6 +79,7 @@ func TestCountDecodeMallocs(t *testing.T) { } } dec := NewDecoder(&buf) + runtime.UpdateMemStats() mallocs := 0 - runtime.MemStats.Mallocs for i := 0; i < count; i++ { *bench = Bench{} @@ -85,6 +88,7 @@ func TestCountDecodeMallocs(t *testing.T) { t.Fatal("decode:", err) } } + runtime.UpdateMemStats() mallocs += runtime.MemStats.Mallocs fmt.Printf("mallocs per decode of type Bench: %d\n", mallocs/count) } |