diff --git a/test/utils_test.go b/test/utils_test.go index 2ed19e1..da48fdb 100644 --- a/test/utils_test.go +++ b/test/utils_test.go @@ -1,9 +1,20 @@ +/* + * @Author: your name + * @Date: 2021-02-27 21:31:29 + * @LastEditTime: 2021-09-20 01:32:26 + * @LastEditors: Please set LastEditors + * @Description: In User Settings Edit + * @FilePath: \background\test\utils_test.go + */ package test import ( "background/utils" + "fmt" "log" + "net" "testing" + "time" ) func TestDDL2ORM(t *testing.T) { @@ -21,3 +32,36 @@ func TestDDL2ORM(t *testing.T) { gocode := utils.CreateGoStruct(tbname,fields) log.Print(gocode) } + + +func TestSpeed(t *testing.T){ + var tcpAddr *net.TCPAddr + tcpAddr,_ = net.ResolveTCPAddr("tcp","192.168.5.133:7") + + conn,err := net.DialTCP("tcp",nil,tcpAddr) + + if err!=nil { + fmt.Println("Client connect error ! " + err.Error()) + return + } + + defer conn.Close() + recv := make([]byte,1024) + fmt.Println(conn.LocalAddr().String() + " : Client connected!") + + reportTime := time.Now() + speed := 0; + for { + cnt,e := conn.Write([]byte("123456")) + speed += cnt + _,e = conn.Read(recv) + if nil != e{ + log.Print(e.Error()) + } + if(reportTime.Add(time.Second).Before(time.Now())){ + reportTime = time.Now() + t.Log("speed ",speed," B/S") + speed = 0 + } + } +} \ No newline at end of file