evio/benchmarks/bench-echo.sh

37 lines
798 B
Bash
Raw Permalink 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-03 23:22:31 +03:00
echo "--- BENCH ECHO START ---"
2017-11-03 04:31:36 +03:00
echo ""
cd $(dirname "${BASH_SOURCE[0]}")
function cleanup {
2017-11-03 23:22:31 +03:00
echo "--- BENCH ECHO DONE ---"
2017-11-04 02:39:28 +03:00
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-echo-server || printf "")
$(pkill -9 evio-echo-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-03 23:22:31 +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, 6 byte packets"
2017-11-03 04:31:36 +03:00
nl=$'\r\n'
2017-11-04 02:39:28 +03:00
tcpkali --workers 1 -c 50 -T 10s -m "PING{$nl}" 127.0.0.1:$4
echo "--- DONE ---"
2017-11-03 04:31:36 +03:00
echo ""
}
2017-11-04 02:39:28 +03:00
gobench "GO STDLIB" bin/net-echo-server net-echo-server/main.go 5001
gobench "EVIO" bin/evio-echo-server ../examples/echo-server/main.go 5002