mirror of https://github.com/cbeuw/Cloak
Add unordered benchmark for RecvDataFromRemote
This commit is contained in:
parent
57bb437802
commit
e0b97db7cc
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"github.com/cbeuw/connutil"
|
"github.com/cbeuw/connutil"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
@ -415,7 +416,7 @@ func TestSession_timeoutAfter(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkRecvDataFromRemote_Ordered(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{
|
||||||
|
|
@ -439,11 +440,17 @@ func BenchmarkRecvDataFromRemote_Ordered(b *testing.B) {
|
||||||
for name, ep := range table {
|
for name, ep := range table {
|
||||||
ep := ep
|
ep := ep
|
||||||
b.Run(name, func(b *testing.B) {
|
b.Run(name, func(b *testing.B) {
|
||||||
seshConfig := seshConfigs["ordered"]
|
for seshType, seshConfig := range seshConfigs {
|
||||||
|
b.Run(seshType, func(b *testing.B) {
|
||||||
obfuscator, _ := MakeObfuscator(ep, sessionKey)
|
obfuscator, _ := MakeObfuscator(ep, sessionKey)
|
||||||
seshConfig.Obfuscator = obfuscator
|
seshConfig.Obfuscator = obfuscator
|
||||||
sesh := MakeSession(0, seshConfig)
|
sesh := MakeSession(0, seshConfig)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
stream, _ := sesh.Accept()
|
||||||
|
stream.(*Stream).WriteTo(ioutil.Discard)
|
||||||
|
}()
|
||||||
|
|
||||||
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)
|
||||||
|
|
@ -459,6 +466,8 @@ func BenchmarkRecvDataFromRemote_Ordered(b *testing.B) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkMultiStreamWrite(b *testing.B) {
|
func BenchmarkMultiStreamWrite(b *testing.B) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue