2017-11-03 04:31:36 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#set -e
|
|
|
|
|
|
|
|
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-03 04:31:36 +03:00
|
|
|
kill $(jobs -rp)
|
|
|
|
wait $(jobs -rp) 2>/dev/null
|
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
|
|
|
mkdir -p bin
|
|
|
|
$(pkill net-echo-server || printf "")
|
|
|
|
$(pkill evio-echo-server || printf "")
|
|
|
|
|
|
|
|
function gobench {
|
|
|
|
printf "\e[96m[%s]\e[0m\n" $1
|
|
|
|
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
|
|
|
|
echo "Sending 6 byte packets, 50 connections"
|
|
|
|
nl=$'\r\n'
|
|
|
|
tcpkali -c 50 -m "PING{$nl}" 127.0.0.1:$4
|
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
|
|
|
|
gobench "net/echo" bin/net-echo-server net-echo-server/main.go 5001
|
|
|
|
gobench "evio/echo" bin/evio-echo-server ../examples/echo-server/main.go 5002
|