aboutsummaryrefslogtreecommitdiffstats
path: root/prog/export_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-08-13 17:02:48 +0200
committerDmitry Vyukov <dvyukov@google.com>2019-08-13 17:02:48 +0200
commitb65356b565286bb1d161cf88d1170168fc9b024c (patch)
tree675eb7154aafc563349a71ae5fef3d15de11827b /prog/export_test.go
parent74d61399c29bb1e38da47fa7fd02a80f06639f7f (diff)
prog: measure memory allocation in benchmarks
Enable ReportAllocs. Also factor out common code into a helper function (duplicated in 3 places now).
Diffstat (limited to 'prog/export_test.go')
-rw-r--r--prog/export_test.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/prog/export_test.go b/prog/export_test.go
index 1aaea30dc..9ea3f612e 100644
--- a/prog/export_test.go
+++ b/prog/export_test.go
@@ -89,3 +89,14 @@ func testEachTargetRandom(t *testing.T, fn func(t *testing.T, target *Target, rs
})
}
}
+
+func initBench(b *testing.B) (*Target, func()) {
+ olddebug := debug
+ debug = false
+ target, err := GetTarget("linux", "amd64")
+ if err != nil {
+ b.Fatal(err)
+ }
+ b.ReportAllocs()
+ return target, func() { debug = olddebug }
+}