diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-06-11 23:14:53 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-06-11 23:34:36 -0400 |
commit | b957093e4fbbf4b423745f5365c06f48ccec20bd (patch) | |
tree | 7e55826c7771b1582cbbf7b79aa4fdb48625cb07 | |
parent | bc6811abf19a8e7ab0fd463f966a874b5982ca2c (diff) | |
download | getwtxt-b957093e4fbbf4b423745f5365c06f48ccec20bd.tar.gz |
apiPostUser benchmark
-rw-r--r-- | svc/post_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
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() + } +} |