-
Notifications
You must be signed in to change notification settings - Fork 13
/
bench-http.sh
executable file
·50 lines (41 loc) · 1.46 KB
/
bench-http.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
#!/bin/bash
set -e
echo ""
echo "--- BENCH HTTP START ---"
echo ""
cd $(dirname "${BASH_SOURCE[0]}")
function cleanup() {
echo "--- BENCH HTTP DONE ---"
kill -9 $(jobs -rp)
wait $(jobs -rp) 2>/dev/null
}
trap cleanup EXIT
mkdir -p bin
$(pkill -9 -f http-net-server || printf "")
$(pkill -9 -f http-fasthttp-server || printf "")
$(pkill -9 -f http-evio-server || printf "")
$(pkill -9 -f http-gnet-server || printf "")
function gobench() {
echo "--- $1 ---"
if [[ "$3" != "" ]]; then
go build -gcflags="-l=4" -ldflags="-s -w" -o $2 $3
fi
if [[ "$1" == "GNET" ]]; then
$2 --port $4 --multicore=$5 &
elif [[ "$1" == "EVIO" ]]; then
$2 --port $4 --loops $5 &
else
$2 --port $4 &
fi
sleep 1
# bombardier -c 256 -d 15s -l http://127.0.0.1:$4
# hey -c 256 -H "Connection: keep-alive" -z 10s -m GET http://127.0.0.1:$4/plaintext
# wrk -t4 -c256 -d15s --latency http://127.0.0.1:$4
wrk -H 'Host: 127.0.0.1' -H 'Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 15 -c 256 --timeout 8 -t 4 http://127.0.0.1:$4/plaintext -s pipeline.lua -- 16
echo "--- DONE ---"
echo ""
}
gobench "GO-HTTP" bin/http-net-server http-net-server/main.go 8081
gobench "FASTHTTP" bin/http-fasthttp-server http-fasthttp-server/main.go 8083
gobench "EVIO" bin/http-evio-server http-evio-server/main.go 8084 -1
gobench "GNET" bin/http-gnet-server http-gnet-server/main.go 8085 true