package server_test import ( "net/http/httptest" "testing" "git.akyoto.dev/go/router/testdata" "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 testdata.Routes("testdata/github.txt") { s.Router.Add(route.Method, route.Path, func(server.Context) error { return nil }) } for range b.N { s.ServeHTTP(response, request) } }