]> Untitled Git - lemmy.git/blob - server/query_testing/api_benchmark.sh
Merge remote-tracking branch 'upstream/master'
[lemmy.git] / server / query_testing / api_benchmark.sh
1 #!/bin/bash
2 set -e
3
4 # By default, this script runs against `http://127.0.0.1:8536`, but you can pass a different Lemmy instance,
5 # eg `./api_benchmark.sh "https://example.com"`.
6 DOMAIN=${1:-"http://127.0.0.1:8536"}
7
8 declare -a arr=(
9 "/api/v1/site"
10 "/api/v1/categories"
11 "/api/v1/modlog"
12 "/api/v1/search?q=test&type_=Posts&sort=Hot"
13 "/api/v1/community"
14 "/api/v1/community/list?sort=Hot"
15 "/api/v1/post/list?sort=Hot&type_=All"
16 )
17
18 ## now loop through the above array
19 for path in "${arr[@]}"
20 do
21   URL="$DOMAIN$path"
22   printf "\n\n\n"
23   echo "testing $URL"
24   curl --show-error --fail --silent "$URL" >/dev/null
25   ab -c 64 -t 10 "$URL" > out.abtest
26   grep "Server Hostname:" out.abtest
27   grep "Document Path:" out.abtest
28   grep "Requests per second" out.abtest
29   grep "(mean, across all concurrent requests)" out.abtest
30   grep "Transfer rate:" out.abtest
31   echo "---"
32 done
33
34 rm *.abtest