package graph import ( "io/ioutil" "os" "testing" "github.com/474420502/focus/compare" "github.com/474420502/focus/tree/avldup" ) func Test1(t *testing.T) { f, err := os.Open("1.xml") if err != nil { panic(err) } data, err := ioutil.ReadAll(f) if err != nil { panic(err) } ParseXML(data) } func BenchmarkF1(b *testing.B) { var law map[rune]bool = make(map[rune]bool) for _, c := range "abcdefghijklmnopqrstuvwsyzABCDEFGHIJKLMNOPQRSTUVWSYZ-_" { law[c] = true } b.ResetTimer() for i := 0; i < b.N; i++ { for _, c := range "abcd%efghij$klmnopq#rstuvwsyz!ABCDEFGHIJ^*KLMNOPQRSTUVWSYZ-_" { if _, ok := law[c]; ok { } } } } func BenchmarkF2(b *testing.B) { tree := avldup.New(compare.Rune) for _, c := range "abcdefghijklmnopqrstuvwsyzABCDEFGHIJKLMNOPQRSTUVWSYZ-_" { tree.Put(c) } b.ResetTimer() for i := 0; i < b.N; i++ { for _, c := range "abcd%efghij$klmnopq#rstuvwsyz!ABCDEFGHIJ^*KLMNOPQRSTUVWSYZ-_" { if _, ok := tree.Get(c); ok { } } } }