-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy path_functions.sh
51 lines (45 loc) · 1.36 KB
/
_functions.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
benchmark ()
{
fw="$1"
url="$2"
ab_log="$output_dir/$fw.ab.log"
output="$output_dir/$fw.output"
echo "ab -c 10 -t 3 $url"
ab -c 10 -t 3 "$url" > "$ab_log"
curl "$url" > "$output"
rps=`grep "Requests per second:" "$ab_log" | cut -f 7 -d " "`
memory=`tail -1 "$output" | cut -f 1 -d ':'`
time=`tail -1 "$output" | cut -f 2 -d ':'`
file=`tail -1 "$output" | cut -f 3 -d ':'`
echo "$fw: $rps: $memory: $time: $file" >> "$results_file"
echo "$fw" >> "$check_file"
grep "Document Length:" "$ab_log" >> "$check_file"
grep "Failed requests:" "$ab_log" >> "$check_file"
grep 'Hello World!' "$output" >> "$check_file"
grep ':' "$output" >> "$check_file"
echo "---" >> "$check_file"
# check errors
touch "$error_file"
error=''
x=`grep 'Failed requests: 0' "$ab_log" || true`
if [ "$x" = "" ]; then
tmp=`grep "Failed requests:" "$ab_log"`
error="$error$tmp"
fi
x=`grep 'Hello World!' "$output" || true`
if [ "$x" = "" ]; then
tmp=`cat "$output"`
error="$error$tmp"
fi
x=`grep ':' "$output" || true`
if [ "$x" = "" ]; then
tmp=`cat "$output"`
error="$error$tmp"
fi
if [ "$error" != "" ]; then
echo -e "$fw\n$error" >> "$error_file"
echo "---" >> "$error_file"
fi
echo "$url" >> "$url_file"
echo
}