github.com/imannamdari/v2ray-core/v5@v5.0.5/common/mux/frame_test.go (about)

     1  package mux_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/imannamdari/v2ray-core/v5/common"
     7  	"github.com/imannamdari/v2ray-core/v5/common/buf"
     8  	"github.com/imannamdari/v2ray-core/v5/common/mux"
     9  	"github.com/imannamdari/v2ray-core/v5/common/net"
    10  )
    11  
    12  func BenchmarkFrameWrite(b *testing.B) {
    13  	frame := mux.FrameMetadata{
    14  		Target:        net.TCPDestination(net.DomainAddress("www.v2fly.org"), 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  }