mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
add benchmark for tcp connection
This commit is contained in:
parent
1740bda985
commit
4211cea92e
1 changed files with 14 additions and 0 deletions
|
@ -2,13 +2,27 @@ package tcp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
log "github.com/schollz/logger"
|
||||||
"github.com/stretchr/testify/assert"
|
"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) {
|
func TestTCP(t *testing.T) {
|
||||||
|
log.SetLevel("error")
|
||||||
timeToRoomDeletion = 100 * time.Millisecond
|
timeToRoomDeletion = 100 * time.Millisecond
|
||||||
go Run("debug", "8281", "pass123", "8282")
|
go Run("debug", "8281", "pass123", "8282")
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue