forked from quic-go/quic-go
wire: optimize generation of Version Negotiation packets (#4278)
* wire: optimize generation of Version Negotiation packets * protocol: optimize adding greased version numbers
This commit is contained in:
@@ -2,6 +2,7 @@ package wire
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/exp/rand"
|
||||
|
||||
@@ -91,3 +92,13 @@ var _ = Describe("Version Negotiation Packets", func() {
|
||||
Expect(reservedVersion&0x0f0f0f0f == 0x0a0a0a0a).To(BeTrue()) // check that it's a greased version number
|
||||
})
|
||||
})
|
||||
|
||||
func BenchmarkComposeVersionNegotiationPacket(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
supportedVersions := []protocol.Version{protocol.Version2, protocol.Version1, 0x1337}
|
||||
destConnID := protocol.ArbitraryLenConnectionID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0xa, 0xb, 0xc, 0xd}
|
||||
srcConnID := protocol.ArbitraryLenConnectionID{10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
|
||||
for i := 0; i < b.N; i++ {
|
||||
ComposeVersionNegotiation(destConnID, srcConnID, supportedVersions)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user