xmltree/graph_test.go

55 lines
999 B
Go
Raw Permalink Normal View History

2019-11-29 10:30:20 +00:00
package graph
import (
"io/ioutil"
"os"
"testing"
2019-12-02 11:38:30 +00:00
"github.com/474420502/focus/compare"
"github.com/474420502/focus/tree/avldup"
2019-11-29 10:30:20 +00:00
)
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)
}
2019-12-02 11:38:30 +00:00
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 {
}
}
}
}