diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-05-04 20:06:00 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-05-04 20:07:32 +0200 |
| commit | 9846445c8e6e35393c6bf8e27a3ac83f70368e63 (patch) | |
| tree | c94cf0b97e8179c55398186db756122d282f1514 /prog/mutation_test.go | |
| parent | 2c7e14a847318974490ab59460f0834ea2ee0d24 (diff) | |
prog: parallelize tests
Parallelize more tests and reduce number of iterations
in random tests under race detector.
Diffstat (limited to 'prog/mutation_test.go')
| -rw-r--r-- | prog/mutation_test.go | 21 |
1 files changed, 17 insertions, 4 deletions
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 +} |
