You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngs/internal/codec/codec_test.go

28 lines
433 B
Go

3 years ago
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")
}
}
}