File: bench_test.go

package info (click to toggle)
golang-github-bmizerany-pat 0.0~git20140625-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 76 kB
  • ctags: 37
  • sloc: makefile: 7
file content (20 lines) | stat: -rw-r--r-- 376 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package pat

import (
	"net/http"
	"testing"
)

func BenchmarkPatternMatching(b *testing.B) {
	p := New()
	p.Get("/hello/:name", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
	for n := 0; n < b.N; n++ {
		b.StopTimer()
		r, err := http.NewRequest("GET", "/hello/blake", nil)
		if err != nil {
			panic(err)
		}
		b.StartTimer()
		p.ServeHTTP(nil, r)
	}
}