raise tcp size

This commit is contained in:
Zack Scholl 2018-09-24 09:36:48 -07:00
parent 15ecc73f67
commit 6635c84f70
3 changed files with 26 additions and 8 deletions

3
go.mod
View File

@ -5,6 +5,7 @@ require (
github.com/dustin/go-humanize v0.0.0-20180713052910-9f541cc9db5d
github.com/fatih/color v1.7.0 // indirect
github.com/gorilla/websocket v1.4.0
github.com/mars9/crypt v0.0.0-20150406101210-65899cf653ff // indirect
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.4 // indirect
github.com/pkg/errors v0.8.0
@ -13,6 +14,8 @@ require (
github.com/schollz/peerdiscovery v1.2.2
github.com/schollz/progressbar/v2 v2.5.3
github.com/schollz/spinner v0.0.0-20180922210718-ea497ee41258
github.com/schollz/utils v1.0.0
github.com/stretchr/testify v1.2.2
github.com/tscholl2/siec v0.0.0-20180721101609-21667da05937
github.com/urfave/cli v1.20.0
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b

View File

@ -13,18 +13,23 @@ import (
"github.com/stretchr/testify/assert"
)
func sendAndReceive(t *testing.T, forceSend int) {
func sendAndReceive(t *testing.T, forceSend int, local bool) {
var startTime time.Time
var durationPerMegabyte float64
megabytes := 10
if local {
megabytes = 100
}
fname := generateRandomFile(megabytes)
var wg sync.WaitGroup
wg.Add(2)
go func() {
defer wg.Done()
c := Init(true)
c.NoLocal = true
c.NoLocal = !local
c.ForceSend = forceSend
c.UseEncryption = false
c.UseEncryption = false
assert.Nil(t, c.Send(fname, "test"))
}()
go func() {
@ -33,7 +38,7 @@ func sendAndReceive(t *testing.T, forceSend int) {
os.MkdirAll("test", 0755)
os.Chdir("test")
c := Init(true)
c.NoLocal = true
c.NoLocal = !local
c.ForceSend = forceSend
startTime = time.Now()
assert.Nil(t, c.Receive("test"))
@ -46,11 +51,21 @@ func sendAndReceive(t *testing.T, forceSend int) {
os.Remove(fname)
fmt.Printf("\n-----\n%2.1f MB/s\n----\n", durationPerMegabyte)
}
func TestSendReceiveWebsockets(t *testing.T) {
sendAndReceive(t, 1)
func TestSendReceivePubWebsockets(t *testing.T) {
sendAndReceive(t, 1, false)
}
func TestSendReceiveTCP(t *testing.T) {
sendAndReceive(t, 2)
func TestSendReceivePubTCP(t *testing.T) {
sendAndReceive(t, 2, false)
}
func TestSendReceiveLocalWebsockets(t *testing.T) {
sendAndReceive(t, 1, true)
}
func TestSendReceiveLocalTCP(t *testing.T) {
sendAndReceive(t, 2, true)
}
func generateRandomFile(megabytes int) (fname string) {

View File

@ -1,4 +1,4 @@
package models
const WEBSOCKET_BUFFER_SIZE = 1024 * 1024 * 32
const TCP_BUFFER_SIZE = 1024 * 2
const TCP_BUFFER_SIZE = 1024 * 64