From b957093e4fbbf4b423745f5365c06f48ccec20bd Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Tue, 11 Jun 2019 23:14:53 -0400 Subject: apiPostUser benchmark --- svc/post_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/svc/post_test.go b/svc/post_test.go index 99c174a..cee324c 100644 --- a/svc/post_test.go +++ b/svc/post_test.go @@ -75,3 +75,23 @@ func Test_apiPostUser(t *testing.T) { }) } } +func Benchmark_apiPostUser(b *testing.B) { + initTestConf() + portnum := fmt.Sprintf(":%v", confObj.Port) + twtxtCache = registry.NewIndex() + + params := url.Values{} + params.Set("url", "https://gbmor.dev/twtxt.txt") + params.Set("nickname", "gbmor") + req, _ := http.NewRequest("POST", "https://localhost"+portnum+"/api/plain/users", strings.NewReader(params.Encode())) + req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + rr := httptest.NewRecorder() + + for i := 0; i < b.N; i++ { + apiEndpointPOSTHandler(rr, req) + + b.StopTimer() + twtxtCache = registry.NewIndex() + b.StartTimer() + } +} -- cgit 1.4.1-2-gfad0