evio/benchmarks/bench-http.sh

38 lines
852 B
Bash
Raw Normal View History

2017-11-03 04:31:36 +03:00
#!/bin/bash
2017-11-04 02:39:28 +03:00
set -e
2017-11-03 04:31:36 +03:00
echo ""
2017-11-04 02:39:28 +03:00
echo "--- BENCH HTTP START ---"
2017-11-03 04:31:36 +03:00
echo ""
cd $(dirname "${BASH_SOURCE[0]}")
function cleanup {
2017-11-04 02:39:28 +03:00
echo "--- BENCH HTTP DONE ---"
kill -9 $(jobs -rp)
2017-11-03 04:31:36 +03:00
wait $(jobs -rp) 2>/dev/null
}
trap cleanup EXIT
mkdir -p bin
2017-11-04 02:39:28 +03:00
$(pkill -9 net-http-server || printf "")
$(pkill -9 fasthttp-server || printf "")
$(pkill -9 evio-http-server || printf "")
2017-11-03 04:31:36 +03:00
function gobench {
2017-11-04 02:39:28 +03:00
echo "--- $1 ---"
2017-11-03 04:31:36 +03:00
if [ "$3" != "" ]; then
go build -o $2 $3
fi
2017-11-04 16:26:00 +03:00
GOMAXPROCS=1 $2 --port $4 &
2017-11-03 04:31:36 +03:00
sleep 1
2017-11-04 02:39:28 +03:00
echo "*** 50 connections, 10 seconds"
2017-11-04 16:26:00 +03:00
bombardier -c 50 http://127.0.0.1:$4
2017-11-04 02:39:28 +03:00
echo "--- DONE ---"
2017-11-03 04:31:36 +03:00
echo ""
}
2017-11-04 02:39:28 +03:00
gobench "GO STDLIB" bin/net-http-server net-http-server/main.go 8081
gobench "FASTHTTP" bin/fasthttp-server fasthttp-server/main.go 8083
gobench "EVIO" bin/evio-http-server ../examples/http-server/main.go 8084