Files
graphene/Examples/common_tools/benchmark-http.sh
Michał Kowalczyk 6c7ff2d3a6 Migrate and remove test/apps submodule
We decided to merge the sample app integrations submodule back because
working with git submodules turned out to be really painful. The only
blocker for this was the fact, that previously it contained a lot of
binary blobs and copy-pasted sources, but this was cleaned up recently.

Credits: (authors of particular integration examples, extracted from
commits and PR history in https://github.com/oscarlab/graphene-tests)

apache:     Chia-Che Tsai <chiache@tamu.edu>, Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
bash:       Chia-Che Tsai <chiache@tamu.edu>, Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
blender:    borysp <borysp@invisiblethingslab.com>
busybox:    borysp <borysp@invisiblethingslab.com>
capnproto:  Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
curl:       Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
gcc:        Thomas Knauth <thomas.knauth@intel.com>
lighttpd:   Chia-Che Tsai <chiache@tamu.edu>, Thomas Knauth <thomas.knauth@intel.com>
lmbench:    Chia-Che Tsai <chiache@tamu.edu>
memcached:  Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
nginx:      Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
nodejs:     jack.wxz <jack.wxz@alibaba-inc.com>
nodejs-express-server: Eduardo Rodriguez <erodrig@us.ibm.com>
openvino:   Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
python-scipy-insecure: Chia-Che Tsai <chiache@tamu.edu>, Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
python-simple:         Chia-Che Tsai <chiache@tamu.edu>, Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
pytorch:    Thomas Knauth <thomas.knauth@intel.com>
r:          Chia-Che Tsai <chiache@tamu.edu>
redis:      Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
tensorflow: Thomas Knauth <thomas.knauth@intel.com>

LTP was moved to LibOS/shim/test/ltp. It was recently rewritten by
Wojtek Porczyk <woju@invisiblethingslab.com>.
2020-03-30 21:10:41 +02:00

50 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# On Ubuntu, this script requires apache2-utils for the ab binary.
#
# Run like: ./benchmark-http.sh host:port
#
# It also works with HTTPS, e.g., ./benchmark-http.sh https://localhost:8443
declare -A THROUGHPUTS
declare -A LATENCIES
LOOP=${LOOP:-1}
DOWNLOAD_HOST=$1
DOWNLOAD_FILE=random/10K.1.html
REQUESTS=10000
CONCURRENCY_LIST=${CONCURRENCY_LIST:-"1 2 4 8 16 32 64 128 256"}
OPTIONS="-k"
RESULT=result-$(date +%y%m%d-%H%M%S)
touch $RESULT
RUN=0
while [ $RUN -lt $LOOP ]
do
for CONCURRENCY in $CONCURRENCY_LIST
do
rm -f OUTPUT
echo "ab $OPTIONS -n $REQUESTS -c $CONCURRENCY $DOWNLOAD_HOST/$DOWNLOAD_FILE"
ab $OPTIONS -n $REQUESTS -c $CONCURRENCY $DOWNLOAD_HOST/$DOWNLOAD_FILE > OUTPUT || exit $?
sleep 5
THROUGHPUT=$(grep -m1 "Requests per second:" OUTPUT | awk '{ print $4 }')
LATENCY=$(grep -m1 "Time per request:" OUTPUT | awk '{ print $4 }')
FAILED=$(grep -m1 "Failed requests:" OUTPUT | awk '{print $3 }')
THROUGHPUTS[$CONCURRENCY]="${THROUGHPUTS[$CONCURRENCY]} $THROUGHPUT"
LATENCIES[$CONCURRENCY]="${LATENCIES[$CONCURRENCY]} $LATENCY"
echo "concurrency=$CONCURRENCY, throughput=$THROUGHPUT, latency=$LATENCY, failed=$FAILED"
done
RUN=$(expr $RUN + 1)
done
for CONCURRENCY in $CONCURRENCY_LIST
do
THROUGHPUT=$(echo ${THROUGHPUTS[$CONCURRENCY]} | tr " " "\n" | sort -n | awk '{a[NR]=$0}END{if(NR%2==1)print a[int(NR/2)+1];else print(a[NR/2-1]+a[NR/2])/2}')
LATENCY=$(echo ${LATENCIES[$CONCURRENCY]} | tr " " "\n" | sort -n | awk '{a[NR]=$0}END{if(NR%2==1)print a[int(NR/2)+1];else print(a[NR/2-1]+a[NR/2])/2}')
echo "$THROUGHPUT,$LATENCY" >> $RESULT
done
echo "Result file: $RESULT"