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"}
12 "/api/v1/search?q=test&type_=Posts&sort=Hot"
14 "/api/v1/community/list?sort=Hot"
15 "/api/v1/post/list?sort=Hot&type_=All"
18 ## check if ab installed
19 if ! [ -x "$(command -v ab)" ]; then
20 echo 'Error: ab (Apache Bench) is not installed. https://httpd.apache.org/docs/2.4/programs/ab.html' >&2
24 ## now loop through the above array
25 for path in "${arr[@]}"
30 curl --show-error --fail --silent "$URL" >/dev/null
31 ab -c 64 -t 10 "$URL" > out.abtest
32 grep "Server Hostname:" out.abtest
33 grep "Document Path:" out.abtest
34 grep "Requests per second" out.abtest
35 grep "(mean, across all concurrent requests)" out.abtest
36 grep "Transfer rate:" out.abtest