package codec import ( . "ng/internal/packet" "testing" ) func BenchmarkDecoder_Decode(b *testing.B) { data := []byte("hello world") pp1, err := Encode(Handshake, data) if err != nil { b.Error(err.Error()) } d1 := NewDecoder() b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { packets, err := d1.Decode(pp1) if err != nil { b.Fatal(err) } if len(packets) != 1 { b.Fatal("decode error") } } }