Add a http performance test script based on wrk 33/5033/1 master
authortrevor tao <trevor.tao@arm.com>
Wed, 9 Nov 2022 07:08:10 +0000 (15:08 +0800)
committertrevor tao <trevor.tao@arm.com>
Wed, 9 Nov 2022 07:08:10 +0000 (15:08 +0800)
Signed-off-by: trevor tao <trevor.tao@arm.com>
Change-Id: I1eb70a0f5211239dc3fa8cfe8d7136fe76360d21

src/tools/wrk_test.sh [new file with mode: 0755]

diff --git a/src/tools/wrk_test.sh b/src/tools/wrk_test.sh
new file mode 100755 (executable)
index 0000000..86cd318
--- /dev/null
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+set -e
+
+accessNum=$((aNum + 0))
+START=1
+END=5
+
+urlIP=${1:-172.26.12.101}
+urlPort=${2:-30942}
+
+IFS_OLD=$IFS
+IFS=$'\n'
+
+
+runCmd(){
+
+for (( c=$START; c<=$END; c++))
+do
+    
+    #curl -w "%{time_total}\n" -o /dev/null -s http://$svcIP
+    cmd=$1
+    echo "Round:"$c"--"$cmd
+    output=$(eval $cmd)
+    #echo $output
+    for line in  $output
+    do
+      #echo "${line}"
+      result=$(echo ${line} | grep "Latency") || true
+      #echo $result
+      if [ "aaa${result}" != "aaa" ]; then
+        latency[$c]=$(echo $result | awk '{print $2}')
+      fi
+      sleep 0.1
+      result=$(echo ${line} | grep "Requests/sec") || true
+      if [ "aaa${result}" != "aaa" ]; then
+        requests[$c]=$(echo $result | awk '{print $2}')
+      fi
+      sleep 0.1
+      result=$(echo ${line} | grep "Transfer/sec") || true
+      if [ "aaa${result}" != "aaa" ]; then
+        transfer[$c]=$(echo $result | awk '{print $2}')
+      fi
+      sleep 0.1
+    done
+
+done 
+
+echo "Latency:"
+for (( c=$START; c<=$END; c++))
+do
+   echo ${latency[$c]}
+done
+
+
+echo "requests/sec:"
+for (( c=$START; c<=$END; c++))
+do
+   echo ${requests[$c]}
+done
+
+
+echo "Transfer/sec:"
+for (( c=$START; c<=$END; c++))
+do
+   echo ${transfer[$c]}
+done
+
+}
+
+runCmd "/usr/bin/wrk -t12 -c400 -d30s http://${urlIP}:${urlPort}"
+runCmd "/usr/bin/wrk -t12 -c400 -d30s http://${urlIP}:${urlPort}/files/file-100K"
+runCmd "/usr/bin/wrk -t12 -c400 -d30s http://${urlIP}:${urlPort}/files/file-1M"
+
+IFS=$IFS_OLD