mirror of https://github.com/cbeuw/Cloak
Fix RecvDataFromRemote benchmark
This commit is contained in:
parent
603b614009
commit
2bcb4a406d
|
|
@ -534,7 +534,7 @@ func TestSession_timeoutAfter(t *testing.T) {
|
||||||
func BenchmarkRecvDataFromRemote(b *testing.B) {
|
func BenchmarkRecvDataFromRemote(b *testing.B) {
|
||||||
testPayload := make([]byte, testPayloadLen)
|
testPayload := make([]byte, testPayloadLen)
|
||||||
rand.Read(testPayload)
|
rand.Read(testPayload)
|
||||||
f := &Frame{
|
f := Frame{
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
|
@ -544,12 +544,13 @@ func BenchmarkRecvDataFromRemote(b *testing.B) {
|
||||||
var sessionKey [32]byte
|
var sessionKey [32]byte
|
||||||
rand.Read(sessionKey[:])
|
rand.Read(sessionKey[:])
|
||||||
|
|
||||||
const maxIter = 100_000 // run with -benchtime 100000x to avoid index out of bounds panic
|
const maxIter = 500_000 // run with -benchtime 500000x to avoid index out of bounds panic
|
||||||
for name, ep := range encryptionMethods {
|
for name, ep := range encryptionMethods {
|
||||||
ep := ep
|
ep := ep
|
||||||
b.Run(name, func(b *testing.B) {
|
b.Run(name, func(b *testing.B) {
|
||||||
for seshType, seshConfig := range seshConfigs {
|
for seshType, seshConfig := range seshConfigs {
|
||||||
b.Run(seshType, func(b *testing.B) {
|
b.Run(seshType, func(b *testing.B) {
|
||||||
|
f := f
|
||||||
seshConfig.Obfuscator, _ = MakeObfuscator(ep, sessionKey)
|
seshConfig.Obfuscator, _ = MakeObfuscator(ep, sessionKey)
|
||||||
sesh := MakeSession(0, seshConfig)
|
sesh := MakeSession(0, seshConfig)
|
||||||
|
|
||||||
|
|
@ -561,7 +562,7 @@ func BenchmarkRecvDataFromRemote(b *testing.B) {
|
||||||
binaryFrames := [maxIter][]byte{}
|
binaryFrames := [maxIter][]byte{}
|
||||||
for i := 0; i < maxIter; i++ {
|
for i := 0; i < maxIter; i++ {
|
||||||
obfsBuf := make([]byte, obfsBufLen)
|
obfsBuf := make([]byte, obfsBufLen)
|
||||||
n, _ := sesh.obfuscate(f, obfsBuf, 0)
|
n, _ := sesh.obfuscate(&f, obfsBuf, 0)
|
||||||
binaryFrames[i] = obfsBuf[:n]
|
binaryFrames[i] = obfsBuf[:n]
|
||||||
f.Seq++
|
f.Seq++
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue