diff options
author | Felix <me@nutomic.com> | 2020-01-28 16:50:40 +0100 |
---|---|---|
committer | Felix <me@nutomic.com> | 2020-01-31 14:17:37 +0100 |
commit | 7b4bf68486ad46b70e761b88be4819d4fc044f91 (patch) | |
tree | 92992e8a69da13a6c1f700affb5d73b68d88d87b /server/query_testing/api_benchmark.sh | |
parent | 8cfd5f9266a0a93dc47ec2ab6060ee0435276aba (diff) |
Add script to test http api, fix two api calls
Diffstat (limited to 'server/query_testing/api_benchmark.sh')
-rwxr-xr-x | server/query_testing/api_benchmark.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/server/query_testing/api_benchmark.sh b/server/query_testing/api_benchmark.sh new file mode 100755 index 00000000..8f8c65f1 --- /dev/null +++ b/server/query_testing/api_benchmark.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -e + +# By default, this script runs against `http://127.0.0.1:8536`, but you can pass a different Lemmy instance, +# eg `./api_benchmark.sh "https://example.com"`. +DOMAIN=${1:-"http://127.0.0.1:8536"} + +declare -a arr=( +"/api/v1/site" +"/api/v1/categories" +"/api/v1/modlog" +"/api/v1/search?q=test&type_=Posts&sort=Hot" +"/api/v1/community" +"/api/v1/community/list?sort=Hot" +"/api/v1/post/list?sort=Hot&type_=All" +) + +## now loop through the above array +for path in "${arr[@]}" +do + URL="$DOMAIN$path" + printf "\n\n\n" + echo "testing $URL" + curl --show-error --fail --silent "$URL" >/dev/null + ab -c 64 -t 10 "$URL" > out.abtest + grep "Server Hostname:" out.abtest + grep "Document Path:" out.abtest + grep "Requests per second" out.abtest + grep "(mean, across all concurrent requests)" out.abtest + grep "Transfer rate:" out.abtest + echo "---" +done + +rm *.abtest |