mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-06 07:06:53 +00:00
Ip限制 npc代理连接
This commit is contained in:
43
vender/github.com/xtaci/kcp/fec_test.go
Normal file
43
vender/github.com/xtaci/kcp/fec_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package kcp
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func BenchmarkFECDecode(b *testing.B) {
|
||||
const dataSize = 10
|
||||
const paritySize = 3
|
||||
const payLoad = 1500
|
||||
decoder := newFECDecoder(1024, dataSize, paritySize)
|
||||
b.ReportAllocs()
|
||||
b.SetBytes(payLoad)
|
||||
for i := 0; i < b.N; i++ {
|
||||
if rand.Int()%(dataSize+paritySize) == 0 { // random loss
|
||||
continue
|
||||
}
|
||||
var pkt fecPacket
|
||||
pkt.seqid = uint32(i)
|
||||
if i%(dataSize+paritySize) >= dataSize {
|
||||
pkt.flag = typeFEC
|
||||
} else {
|
||||
pkt.flag = typeData
|
||||
}
|
||||
pkt.data = make([]byte, payLoad)
|
||||
decoder.decode(pkt)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkFECEncode(b *testing.B) {
|
||||
const dataSize = 10
|
||||
const paritySize = 3
|
||||
const payLoad = 1500
|
||||
|
||||
b.ReportAllocs()
|
||||
b.SetBytes(payLoad)
|
||||
encoder := newFECEncoder(dataSize, paritySize, 0)
|
||||
for i := 0; i < b.N; i++ {
|
||||
data := make([]byte, payLoad)
|
||||
encoder.encode(data)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user