summary refs log tree commit diff stats
path: root/svc
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-06-11 23:14:53 -0400
committerBen Morrison <ben@gbmor.dev>2019-06-11 23:34:36 -0400
commitb957093e4fbbf4b423745f5365c06f48ccec20bd (patch)
tree7e55826c7771b1582cbbf7b79aa4fdb48625cb07 /svc
parentbc6811abf19a8e7ab0fd463f966a874b5982ca2c (diff)
downloadgetwtxt-b957093e4fbbf4b423745f5365c06f48ccec20bd.tar.gz
apiPostUser benchmark
Diffstat (limited to 'svc')
-rw-r--r--svc/post_test.go20
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()
+	}
+}