summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2012-02-19 22:13:04 -0500
committerRuss Cox <rsc@golang.org>2012-02-19 22:13:04 -0500
commitd39a928e4c4a07e271067df29e9dbd0c3f2b5a67 (patch)
tree8e6e6d34ff67b7c275665fbe3c9f0255fa26bcfa
parent198b90c3ad38fb9e576f77e1eaf03f6516aa776d (diff)
downloadgo-d39a928e4c4a07e271067df29e9dbd0c3f2b5a67.tar.gz
strconv: run garbage collection before counting allocations in test
My theory is that the call to f() allocates, which triggers a garbage collection, which itself may do some allocation, which is being counted. Running a garbage collection before starting the test should avoid this problem. Fixes issue 2894 (I hope). R=golang-dev, bradfitz, nigeltao CC=golang-dev http://codereview.appspot.com/5685046
-rw-r--r--src/pkg/strconv/itoa_test.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/pkg/strconv/itoa_test.go b/src/pkg/strconv/itoa_test.go
index 6687314d2..1486ee214 100644
--- a/src/pkg/strconv/itoa_test.go
+++ b/src/pkg/strconv/itoa_test.go
@@ -127,6 +127,7 @@ func TestUitoa(t *testing.T) {
}
func numAllocations(f func()) int {
+ runtime.GC()
memstats := new(runtime.MemStats)
runtime.ReadMemStats(memstats)
n0 := memstats.Mallocs