From 9846445c8e6e35393c6bf8e27a3ac83f70368e63 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 4 May 2018 20:06:00 +0200 Subject: prog: parallelize tests Parallelize more tests and reduce number of iterations in random tests under race detector. --- prog/mutation_test.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'prog/mutation_test.go') diff --git a/prog/mutation_test.go b/prog/mutation_test.go index 2267dd254..23f994c84 100644 --- a/prog/mutation_test.go +++ b/prog/mutation_test.go @@ -7,6 +7,7 @@ import ( "bytes" "fmt" "math/rand" + "sync" "testing" ) @@ -194,10 +195,10 @@ func BenchmarkMutate(b *testing.B) { if err != nil { b.Fatal(err) } - prios := target.CalculatePriorities(nil) - ct := target.BuildChoiceTable(prios, nil) + ct := linuxAmd64ChoiceTable(target) const progLen = 30 p := target.Generate(rand.NewSource(0), progLen, nil) + b.ResetTimer() b.RunParallel(func(pb *testing.PB) { rs := rand.NewSource(0) for pb.Next() { @@ -214,9 +215,9 @@ func BenchmarkGenerate(b *testing.B) { if err != nil { b.Fatal(err) } - prios := target.CalculatePriorities(nil) - ct := target.BuildChoiceTable(prios, nil) + ct := linuxAmd64ChoiceTable(target) const progLen = 30 + b.ResetTimer() b.RunParallel(func(pb *testing.PB) { rs := rand.NewSource(0) for pb.Next() { @@ -224,3 +225,15 @@ func BenchmarkGenerate(b *testing.B) { } }) } + +var ( + linuxCTOnce sync.Once + linuxCT *ChoiceTable +) + +func linuxAmd64ChoiceTable(target *Target) *ChoiceTable { + linuxCTOnce.Do(func() { + linuxCT = target.BuildChoiceTable(target.CalculatePriorities(nil), nil) + }) + return linuxCT +} -- cgit mrf-deployment