github.com/Uhtred009/v2ray-core-1@v4.31.2+incompatible/common/strmatcher/benchmark_test.go (about) 1 package strmatcher_test 2 3 import ( 4 "strconv" 5 "testing" 6 7 "v2ray.com/core/common" 8 . "v2ray.com/core/common/strmatcher" 9 ) 10 11 func BenchmarkDomainMatcherGroup(b *testing.B) { 12 g := new(DomainMatcherGroup) 13 14 for i := 1; i <= 1024; i++ { 15 g.Add(strconv.Itoa(i)+".v2ray.com", uint32(i)) 16 } 17 18 b.ResetTimer() 19 for i := 0; i < b.N; i++ { 20 _ = g.Match("0.v2ray.com") 21 } 22 } 23 24 func BenchmarkFullMatcherGroup(b *testing.B) { 25 g := new(FullMatcherGroup) 26 27 for i := 1; i <= 1024; i++ { 28 g.Add(strconv.Itoa(i)+".v2ray.com", uint32(i)) 29 } 30 31 b.ResetTimer() 32 for i := 0; i < b.N; i++ { 33 _ = g.Match("0.v2ray.com") 34 } 35 } 36 37 func BenchmarkMarchGroup(b *testing.B) { 38 g := new(MatcherGroup) 39 for i := 1; i <= 1024; i++ { 40 m, err := Domain.New(strconv.Itoa(i) + ".v2ray.com") 41 common.Must(err) 42 g.Add(m) 43 } 44 45 b.ResetTimer() 46 for i := 0; i < b.N; i++ { 47 _ = g.Match("0.v2ray.com") 48 } 49 }