39 lines
725 B
Go
Raw Normal View History

2024-03-12 19:35:19 +00:00
package server_test
import (
"net/http/httptest"
"testing"
"git.akyoto.dev/go/server"
)
func BenchmarkHello(b *testing.B) {
request := httptest.NewRequest("GET", "/", nil)
response := &NullResponse{}
s := server.New()
s.Get("/", func(ctx server.Context) error {
return ctx.String("Hello")
})
for range b.N {
s.ServeHTTP(response, request)
}
}
func BenchmarkGitHub(b *testing.B) {
request := httptest.NewRequest("GET", "/repos/:owner/:repo", nil)
response := &NullResponse{}
s := server.New()
for _, route := range loadRoutes("testdata/github.txt") {
s.Router().Add(route.Method, route.Path, func(server.Context) error {
return nil
})
}
for range b.N {
s.ServeHTTP(response, request)
}
}