Renamed test file
This commit is contained in:
parent
1dc158eb03
commit
5a8de525a4
1 changed files with 0 additions and 0 deletions
|
@ -1,63 +0,0 @@
|
|||
package web_test
|
||||
|
||||
import (
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.akyoto.dev/go/router/testdata"
|
||||
"git.akyoto.dev/go/web"
|
||||
)
|
||||
|
||||
func BenchmarkStatic(b *testing.B) {
|
||||
paths := []string{
|
||||
"/",
|
||||
"/hello",
|
||||
"/hello/world",
|
||||
}
|
||||
|
||||
s := web.NewServer()
|
||||
|
||||
for _, path := range paths {
|
||||
s.Get(path, func(ctx web.Context) error {
|
||||
return ctx.String("Hello")
|
||||
})
|
||||
}
|
||||
|
||||
for _, path := range paths {
|
||||
b.Run(strings.TrimPrefix(path, "/"), func(b *testing.B) {
|
||||
request := httptest.NewRequest("GET", path, nil)
|
||||
response := &NullResponse{}
|
||||
|
||||
for range b.N {
|
||||
s.ServeHTTP(response, request)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkGitHub(b *testing.B) {
|
||||
paths := []string{
|
||||
"/gists/:id",
|
||||
"/repos/:a/:b",
|
||||
}
|
||||
|
||||
s := web.NewServer()
|
||||
|
||||
for _, route := range testdata.Routes("testdata/github.txt") {
|
||||
s.Router().Add(route.Method, route.Path, func(ctx web.Context) error {
|
||||
return ctx.String("Hello")
|
||||
})
|
||||
}
|
||||
|
||||
for _, path := range paths {
|
||||
b.Run(strings.TrimPrefix(path, "/"), func(b *testing.B) {
|
||||
request := httptest.NewRequest("GET", path, nil)
|
||||
response := &NullResponse{}
|
||||
|
||||
for range b.N {
|
||||
s.ServeHTTP(response, request)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue