github.com/xmplusdev/xmcore@v1.8.11-0.20240412132628-5518b55526af/common/mux/frame_test.go (about) 1 package mux_test 2 3 import ( 4 "testing" 5 6 "github.com/xmplusdev/xmcore/common" 7 "github.com/xmplusdev/xmcore/common/buf" 8 "github.com/xmplusdev/xmcore/common/mux" 9 "github.com/xmplusdev/xmcore/common/net" 10 ) 11 12 func BenchmarkFrameWrite(b *testing.B) { 13 frame := mux.FrameMetadata{ 14 Target: net.TCPDestination(net.DomainAddress("www.example.com"), net.Port(80)), 15 SessionID: 1, 16 SessionStatus: mux.SessionStatusNew, 17 } 18 writer := buf.New() 19 defer writer.Release() 20 21 for i := 0; i < b.N; i++ { 22 common.Must(frame.WriteTo(writer)) 23 writer.Clear() 24 } 25 }