Add benchmark for pk.Packet.packWithCompression()

This commit is contained in:
Tnze
2023-04-05 22:24:06 +08:00
parent 48a6956090
commit 943d9fbe26

View File

@ -80,7 +80,7 @@ func ExampleMarshal_setSlot() {
// 15 00 00 05 01 01 01 03 00 00 12 34 56 78
}
func BenchmarkPacket_Pack(b *testing.B) {
func BenchmarkPacket_Pack_packWithoutCompression(b *testing.B) {
p := pk.Packet{ID: 0, Data: make([]byte, 64)}
b.ResetTimer()
for i := 0; i < b.N; i++ {
@ -89,3 +89,13 @@ func BenchmarkPacket_Pack(b *testing.B) {
}
}
}
func BenchmarkPacket_Pack_packWithCompression(b *testing.B) {
p := pk.Packet{ID: 0, Data: make([]byte, 64)}
b.ResetTimer()
for i := 0; i < b.N; i++ {
if err := p.Pack(io.Discard, 32); err != nil {
b.Fatal(err)
}
}
}