diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2019-08-13 17:02:48 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-08-13 17:02:48 +0200 |
| commit | b65356b565286bb1d161cf88d1170168fc9b024c (patch) | |
| tree | 675eb7154aafc563349a71ae5fef3d15de11827b /prog/mutation_test.go | |
| parent | 74d61399c29bb1e38da47fa7fd02a80f06639f7f (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/mutation_test.go')
| -rw-r--r-- | prog/mutation_test.go | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/prog/mutation_test.go b/prog/mutation_test.go index 6b50b975e..b041f02d2 100644 --- a/prog/mutation_test.go +++ b/prog/mutation_test.go @@ -220,13 +220,8 @@ func runMutationTests(t *testing.T, tests [][2]string) { } func BenchmarkMutate(b *testing.B) { - olddebug := debug - debug = false - defer func() { debug = olddebug }() - target, err := GetTarget("linux", "amd64") - if err != nil { - b.Fatal(err) - } + target, cleanup := initBench(b) + defer cleanup() ct := linuxAmd64ChoiceTable(target) const progLen = 30 p := target.Generate(rand.NewSource(0), progLen, nil) @@ -240,13 +235,8 @@ func BenchmarkMutate(b *testing.B) { } func BenchmarkGenerate(b *testing.B) { - olddebug := debug - debug = false - defer func() { debug = olddebug }() - target, err := GetTarget("linux", "amd64") - if err != nil { - b.Fatal(err) - } + target, cleanup := initBench(b) + defer cleanup() ct := linuxAmd64ChoiceTable(target) const progLen = 30 b.ResetTimer() |
