diff --git a/bj-rtss-message b/bj-rtss-message new file mode 160000 index 0000000..c09c465 --- /dev/null +++ b/bj-rtss-message @@ -0,0 +1 @@ +Subproject commit c09c46511d43178e55491efeab848445ea35ddbf diff --git a/dynamics/udp_test.go b/dynamics/udp_test.go index 8b60f2e..bf5a54d 100644 --- a/dynamics/udp_test.go +++ b/dynamics/udp_test.go @@ -1,8 +1,14 @@ package dynamics import ( + "encoding/hex" + "github.com/panjf2000/gnet/v2" + "io" "joylink.club/bj-rtsts-server/config" + "net" + "runtime" "testing" + "time" ) func TestRunUdpServer(t *testing.T) { @@ -19,3 +25,173 @@ func TestSendTurnoutInfo(t *testing.T) { RPosition: false, }) } + +func BenchmarkUdpServer_OnTraffic(b *testing.B) { + runtime.GOMAXPROCS(1) //1个协程 + buf, _ := hex.DecodeString("0009012EE009000000070380000006000100020003000A000A000A000A000A000A000A") + // 创建 udpServer 对象 + server := &udpServer{} + // 创建虚拟的 gnet.Conn 对象 + conn := &virtualConn{ + readBuffer: buf, + } + + // 在 Benchmark 中运行测试 + for i := 0; i < b.N; i++ { + server.OnTraffic(conn) + } +} + +type virtualConn struct { + readBuffer []byte +} + +func (vc *virtualConn) Read(p []byte) (n int, err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) Write(p []byte) (n int, err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) Context() (ctx interface{}) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) SetContext(ctx interface{}) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) Close() (err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) WriteTo(w io.Writer) (n int64, err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) Next(n int) (buf []byte, err error) { + //TODO implement me + return vc.readBuffer, nil +} + +func (vc *virtualConn) Peek(n int) (buf []byte, err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) Discard(n int) (discarded int, err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) InboundBuffered() (n int) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) ReadFrom(r io.Reader) (n int64, err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) Writev(bs [][]byte) (n int, err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) Flush() (err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) OutboundBuffered() (n int) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) AsyncWrite(buf []byte, callback gnet.AsyncCallback) (err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) AsyncWritev(bs [][]byte, callback gnet.AsyncCallback) (err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) Fd() int { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) Dup() (int, error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) SetReadBuffer(bytes int) error { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) SetWriteBuffer(bytes int) error { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) SetLinger(sec int) error { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) SetKeepAlivePeriod(d time.Duration) error { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) SetNoDelay(noDelay bool) error { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) LocalAddr() (addr net.Addr) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) RemoteAddr() (addr net.Addr) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) Wake(callback gnet.AsyncCallback) (err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) CloseWithCallback(callback gnet.AsyncCallback) (err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) SetDeadline(t time.Time) (err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) SetReadDeadline(t time.Time) (err error) { + //TODO implement me + panic("implement me") +} + +func (vc *virtualConn) SetWriteDeadline(t time.Time) (err error) { + //TODO implement me + panic("implement me") +} diff --git a/protobuf/main/generator_test.go b/protobuf/main/generator_test.go new file mode 100644 index 0000000..7905807 --- /dev/null +++ b/protobuf/main/generator_test.go @@ -0,0 +1,5 @@ +package main + +func main() { + +}