-
Notifications
You must be signed in to change notification settings - Fork 1
/
eva_apache2.sh
executable file
·52 lines (41 loc) · 1.12 KB
/
eva_apache2.sh
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
46
47
48
49
50
51
52
#!/bin/bash
fname=$1
resdir=/tmp/eva_apache2
resfile=$resdir/res.tmp.$fname
rm -rf $resfile
mkdir -p $resdir
IP="192.168.2.2:8180"
FILE="file-4kb"
apache_bench=ab
reqs=10000
conc=32
function run_test(){
idx=$1
echo "$($apache_bench -n $reqs -c $conc $IP/$FILE 2>&1)" \
| grep -E 'Time taken for tests|Requests per' \
| tee -a $resfile
echo "<------------- done iter $idx --------------->"
}
ITER=1
for i in $(seq 1 $ITER); do
run_test $i
done
# # report
# all_time=0
# time_count=0
# all_reqs=0
# req_count=0
# while IFS= read -r line; do
# if [[ "$line" == *"Time taken for tests"* ]]; then
# per_time=$(echo "$line" | awk '{print $5}')
# all_time=$(bc <<< "$all_time + $per_time")
# time_count=$((time_count + 1))
# elif [[ "$line" == *"Requests per"* ]]; then
# per_reqs=$(echo "$line" | awk '{print $4}')
# all_reqs=$(bc <<< "$all_reqs + $per_reqs")
# req_count=$((req_count + 1))
# fi
# done < $resfile
# avg_time=$(bc <<< "scale=2; $all_time / $time_count")
# avg_reqs=$(bc <<< "scale=2; $all_reqs / $req_count")
# echo -e "\nAvg time: $avg_time. Avg req/s: $avg_reqs." | tee -a $resfile