Skip to content

Commit

Permalink
single proc
Browse files Browse the repository at this point in the history
  • Loading branch information
tidwall committed Nov 3, 2017
1 parent 3b33b0c commit da18955
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
8 changes: 3 additions & 5 deletions benchmarks/bench-echo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
#set -e

echo ""
echo "--- ECHO START ---"
echo "--- BENCH ECHO START ---"
echo ""

cd $(dirname "${BASH_SOURCE[0]}")
function cleanup {
echo "--- ECHO DONE ---"
echo "--- BENCH ECHO DONE ---"
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 "")

Expand All @@ -24,12 +23,11 @@ function gobench {
if [ "$3" != "" ]; then
go build -o $2 $3
fi
$2 -port $4 &
GOMAXPROCS=1 $2 --port $4 &
sleep 1
echo "Sending 6 byte packets, 50 connections"
nl=$'\r\n'
tcpkali -c 50 -m "PING{$nl}" 127.0.0.1:$4
echo "--- DONE ---"
echo ""
}

Expand Down
7 changes: 3 additions & 4 deletions benchmarks/bench-http.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ function gobench {
if [ "$3" != "" ]; then
go build -o $2 $3
fi
$2 -port $4 &
GOMAXPROCS=1 $2 --port $4 &
sleep 1
echo "Using 4 threads, 50 connections, 10 seconds"
wrk -t4 -c50 -d10 http://127.0.0.1:$4
echo "--- DONE ---"
echo "Using 50 connections, 10 seconds"
wrk -t1 -c50 -d10 http://127.0.0.1:$4
echo ""
}

Expand Down
9 changes: 3 additions & 6 deletions benchmarks/bench-redis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
#set -e

echo ""
echo "--- REDIS START ---"
echo "--- BENCH REDIS START ---"
echo ""


cd $(dirname "${BASH_SOURCE[0]}")
function cleanup {
echo "--- REDIS DONE ---"
echo "--- BENCH REDIS DONE ---"
kill $(jobs -rp)
wait $(jobs -rp) 2>/dev/null
}
trap cleanup EXIT

mkdir -p bin

$(pkill redis-server || printf "")
$(pkill evio-redis-server || printf "")

Expand All @@ -25,15 +23,14 @@ function gobench {
if [ "$3" != "" ]; then
go build -o $2 $3
fi
$2 --port $4 &
GOMAXPROCS=1 $2 --port $4 &
sleep 1
echo "Sending pings, 50 connections, 1 packet pipeline"
redis-benchmark -p $4 -t ping -q -P 1
echo "Sending pings, 50 connections, 10 packet pipeline"
redis-benchmark -p $4 -t ping -q -P 10
echo "Sending pings, 50 connections, 20 packet pipeline"
redis-benchmark -p $4 -t ping -q -P 20
echo "--- DONE ---"
echo ""
}
gobench "real/redis" redis-server "" 6392
Expand Down
File renamed without changes.
7 changes: 2 additions & 5 deletions evio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,6 @@ func TestBadAddresses(t *testing.T) {
if err := Serve(events, "howdy"); err == nil {
t.Fatalf("expected error")
}
if err := Serve(events, "unix://"); err == nil {
t.Fatalf("expected error")
}
if err := Serve(events, "tcp://"); err != nil {
t.Fatalf("expected nil, got '%v'", err)
}
Expand Down Expand Up @@ -670,7 +667,7 @@ func testTranslate(network, addr string, kind string, stdlib bool) {
func(id int, addr Addr) bool {
return true
},
func(rw io.ReadWriter) io.ReadWriter {
func(id int, rw io.ReadWriter) io.ReadWriter {
switch kind {
case "passthrough":
return rw
Expand All @@ -690,7 +687,7 @@ func testTranslate(network, addr string, kind string, stdlib bool) {
func(id int, addr Addr) bool {
return false
},
func(rw io.ReadWriter) io.ReadWriter {
func(id int, rw io.ReadWriter) io.ReadWriter {
return rw
},
)
Expand Down
6 changes: 6 additions & 0 deletions examples/http-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ func main() {
var tlsport int
var tlspem string
var aaaa bool
var noparse bool

flag.IntVar(&port, "port", 8080, "server port")
flag.IntVar(&tlsport, "tlsport", 4443, "tls port")
flag.StringVar(&tlspem, "tlscert", "", "tls pem cert/key file")
flag.BoolVar(&aaaa, "aaaa", false, "aaaaa....")
flag.BoolVar(&noparse, "noparse", true, "do not parse requests")
flag.Parse()

if aaaa {
Expand Down Expand Up @@ -78,6 +80,10 @@ func main() {
if in == nil {
return
}
if noparse {
out = []byte("HTTP/1.1 200 OK\r\nServer: evio\r\nDate: Fri, 03 Nov 2017 11:37:00 GMT\r\nContent-Length: 14\r\n\r\nHello World!\r\n")
return
}
c := conns[id]
data := c.is.Begin(in)
// process the pipeline
Expand Down

0 comments on commit da18955

Please sign in to comment.