-
Notifications
You must be signed in to change notification settings - Fork 0
/
ab_test
executable file
·46 lines (32 loc) · 967 Bytes
/
ab_test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
url="http://localhost:8080/"
concurrency=100
requests=10000
cpu_core=7
sum=0
count=10
min=99999999
max=0
sum_l90=0
sum_freq=0
for (( i=0;i<$count;i++)); do
result=`taskset -c $cpu_core ab -q -n$requests -c$concurrency $url`
rps=`echo -e -n "$result" | grep "Requests per second" | grep -o -P "[0-9\.]+" `
l90=`echo -e -n "$result" | grep "90%" | awk {'print $2'}`
freq=`echo -e -n "$result" | grep "Failed requests" | awk {'print $3'}`
printf "#%3.3d. " "$i"
echo -e "rs=$rps l90=$l90 f_req=$freq"
sum=`echo $sum+$rps | bc`
sum_l90=`echo $sum_l90+$l90 | bc`
sum_freq=`echo $sum_freq+$freq | bc`
resultint=`echo $rps | tr . " " | awk {'print $1'}`
if [ $resultint -gt $max ]; then
max=$resultint
fi
if [ $resultint -lt $min ]; then
min=$resultint
fi
done
result=`echo $sum/$count | bc`
avg_l90=`echo $sum_l90/$count | bc`
echo -e "\nmin=$min avg=$result max=$max avg_l90=$avg_l90 sum_freq=$sum_freq\n"