Skip to content

Commit

Permalink
[CI-Examples] Fix wrong throughput unit in benchmark-http.sh
Browse files Browse the repository at this point in the history
Previously, we were printing the throughput in bytes, but wrk2 gives
"Req/Sec" and the throughput in bytes doesn't really make sense.

Additionally, this commit adds a note in the README of our rust example
stating the need of `wrk2` when using the benchmark script.

Signed-off-by: Kailun Qin <kailun.qin@intel.com>
  • Loading branch information
kailun-qin committed Mar 15, 2024
1 parent e3d3aa3 commit f10b434
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CI-Examples/common_tools/benchmark-http.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CONCURRENCY_LIST=${CONCURRENCY_LIST:-"1 2 4 8 16 32 64 128 256"}
RESULT=result-$(date +%y%m%d-%H%M%S)

touch "$RESULT"
throughput_in_bytes() {
convert_throughput() {
local THROUGHPUT_VAL=0
local THROUGHPUT_UNIT=""
if [[ "$1" =~ ^([0-9]*)(\.[0-9]*)?([kMG]?)$ ]]; then
Expand Down Expand Up @@ -79,7 +79,7 @@ do
wrk -c "$CONNECTIONS" -d "$DURATION" -t "$CONCURRENCY" -R "$REQUESTS" "$DOWNLOAD_HOST/$DOWNLOAD_FILE" > OUTPUT || exit $?

THROUGHPUT_STR=$(grep -m1 "Req/Sec" OUTPUT | awk '{ print $2 }')
THROUGHPUT=$(throughput_in_bytes "$THROUGHPUT_STR")
THROUGHPUT=$(convert_throughput "$THROUGHPUT_STR")
if [ "$THROUGHPUT" = "0" ]; then
echo "Throughput is zero!"; exit 1;
fi
Expand All @@ -97,7 +97,7 @@ do
THROUGHPUTS[$CONCURRENCY]="${THROUGHPUTS[$CONCURRENCY]} $THROUGHPUT"
LATENCIES[$CONCURRENCY]="${LATENCIES[$CONCURRENCY]} $LATENCY"
fi
echo "Run = $((RUN+1)) Concurrency = $CONCURRENCY Per thread Throughput (bytes) = $THROUGHPUT, Latency (ms) = $LATENCY"
echo "Run = $((RUN+1)) Concurrency = $CONCURRENCY Per thread Throughput (req/sec) = $THROUGHPUT, Latency (ms) = $LATENCY"

done
(( RUN++ ))
Expand All @@ -107,7 +107,7 @@ 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[(NR + 1)/2];else print (a[NR/2]+a[NR/2 + 1])/2}')
LATENCY=$(echo "${LATENCIES[$CONCURRENCY]}" | tr " " "\n" | sort -n | awk '{a[NR]=$0}END{if(NR%2==1)print a[(NR + 1)/2];else print (a[NR/2]+a[NR/2 + 1])/2}')
printf "Concurrency = %3d: Per Thread Median Througput (bytes) = %9.3f, Latency (ms) = %9.3f\n" \
printf "Concurrency = %3d: Per Thread Median Througput (req/sec) = %9.3f, Latency (ms) = %9.3f\n" \
"$CONCURRENCY" "$THROUGHPUT" "$LATENCY" | tee -a "$RESULT"
done

Expand Down
3 changes: 3 additions & 0 deletions CI-Examples/rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ The bind address and port are hardcoded in `src/main.rs`.

# Quick Start

NOTE: The "benchmark-http.sh" script uses the wrk benchmark (wrk2) under the
hood. Please refer to https://github.com/giltene/wrk2.

```sh
# build the program and the final manifest
make SGX=1
Expand Down

0 comments on commit f10b434

Please sign in to comment.