From 4211cea92e450e5465a5b6a17437752a3a368ce6 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Wed, 6 May 2020 10:18:39 -0700 Subject: [PATCH] add benchmark for tcp connection --- src/tcp/tcp_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/tcp/tcp_test.go b/src/tcp/tcp_test.go index e1986e7a..fda31f23 100644 --- a/src/tcp/tcp_test.go +++ b/src/tcp/tcp_test.go @@ -2,13 +2,27 @@ package tcp import ( "bytes" + "fmt" "testing" "time" + log "github.com/schollz/logger" "github.com/stretchr/testify/assert" ) +func BenchmarkConnection(b *testing.B) { + log.SetLevel("trace") + go Run("debug", "8283", "pass123", "8284") + time.Sleep(100 * time.Millisecond) + b.ResetTimer() + for i := 0; i < b.N; i++ { + c, _, _, _ := ConnectToTCPServer("localhost:8283", "pass123", fmt.Sprintf("testroom%d", i), 1*time.Minute) + c.Close() + } +} + func TestTCP(t *testing.T) { + log.SetLevel("error") timeToRoomDeletion = 100 * time.Millisecond go Run("debug", "8281", "pass123", "8282") time.Sleep(100 * time.Millisecond)