예제 #1
0
func (s *MatchSuite) BenchmarkMatching(c *C) {
	rndString := testutils.NewRndString()

	m := NewPathRouter()
	loc := &Loc{Name: "a"}

	for i := 0; i < 100; i++ {
		err := m.AddLocation(rndString.MakePath(20, 10), loc)
		c.Assert(err, IsNil)
	}

	req := request(fmt.Sprintf("http://google.com/%s", rndString.MakePath(20, 10)))
	for i := 0; i < c.N; i++ {
		m.Route(req)
	}
}
예제 #2
0
func (s *TrieSuite) BenchmarkMatching(c *C) {
	rndString := testutils.NewRndString()
	l := makeLoc("loc")

	t, _ := makeTrie(c, rndString.MakePath(20, 10), l)

	for i := 0; i < 10000; i++ {
		t2, _ := makeTrie(c, rndString.MakePath(20, 10), l)
		out, err := t.merge(t2)
		if err != nil {
			c.Assert(err, IsNil)
		}
		t = out.(*trie)
	}
	req := makeReq(fmt.Sprintf("http://google.com/%s", rndString.MakePath(20, 10)))
	for i := 0; i < c.N; i++ {
		t.match(req)
	}
}