-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·92 lines (65 loc) · 1.76 KB
/
run
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
#
# author: Lucas Stephanou
# source: http://github.com/lucasts/Async_Test
#
echo "*******************************************"
echo "******Evented/NIO Benchmark****************"
## definitions
ab="/usr/sbin/ab"
reqs=$1
conc=$2
#default port
port=8123
implementations=( "tornado" "thin" "twisted" "nodejs" "apache")
cmds=( "python tornado/hello.py" "thin start -R -p "$port" thin/hello.ru" "python twisted/hello.py" "node nodejs/hello.js" "")
apache_test_url="http://127.0.0.1/~lucas/async.html"
summaryfile=summary.txt
# clean results
rm -Rf ./results/*
rm $summaryfile
touch $summaryfile
# go go go
x=0
while [ $x != ${#implementations[@]} ]
do
resultfile="results/"${implementations[$x]}".txt"
echo "Starting " ${implementations[$x]}
touch $resultfile
echo " >> "${cmds[$x]}
${cmds[$x]} &
spid=$!
sleep 3
echo " >> benchmarking..."
for i in 1 2 3 4 5
do
echo " >> ab $i"
if [ ${implementations[$x]} == "apache" ]
then
$ab -n $reqs -c $conc $apache_test_url >> $resultfile
else
$ab -n $reqs -c $conc "http://127.0.0.1:"$port"/" >> $resultfile
fi
done
echo " >> calculating results..."
avg=$(egrep 'Requests per second.*([1-9]*)' $resultfile|awk '{sum += $4;}END{print sum/5}')
echo ""${implementations[$x]}":"$avg"" >> $summaryfile
# debug #echo ""${implementations[$x]}" : "${files[$x]}""
trash=$(/bin/kill $spid > /dev/null 2> /dev/null)
stty echo
let "x = x +1"
done
echo "*******************************************"
echo "Summary file ok"
# test mathplotlib
mpl=$(python -c '
try:
import pylab
print 0
except:
print 1
')
if [ "$mpl" = "0" ]; then
echo "******mathplotlib ok - gererating graph****"
python plot.py
fi