Improve comments

pull/132/head
Andy Wang 4 years ago
parent afbc87162c
commit a86899f007

@ -111,6 +111,7 @@ func parseProxyBook(bookEntries map[string][]string) (map[string]net.Addr, error
return proxyBook, nil return proxyBook, nil
} }
// ParseConfig reads the config file or semicolon-separated options and parse them into a RawConfig
func ParseConfig(conf string) (raw RawConfig, err error) { func ParseConfig(conf string) (raw RawConfig, err error) {
content, errPath := ioutil.ReadFile(conf) content, errPath := ioutil.ReadFile(conf)
if errPath != nil { if errPath != nil {
@ -132,7 +133,7 @@ func ParseConfig(conf string) (raw RawConfig, err error) {
return return
} }
// ParseConfig parses the config (either a path to json or the json itself as argument) into a State variable // InitState process the RawConfig and initialises a server State accordingly
func InitState(preParse RawConfig, worldState common.WorldState) (sta *State, err error) { func InitState(preParse RawConfig, worldState common.WorldState) (sta *State, err error) {
sta = &State{ sta = &State{
BypassUID: make(map[[16]byte]struct{}), BypassUID: make(map[[16]byte]struct{}),

@ -528,9 +528,10 @@ func BenchmarkThroughput(b *testing.B) {
b.Fatal(err) b.Fatal(err)
} }
b.Run("single conn", func(b *testing.B) { b.Run("single stream", func(b *testing.B) {
more := make(chan int, 10) more := make(chan int, 10)
go func() { go func() {
// sender
writeBuf := make([]byte, bufSize+100) writeBuf := make([]byte, bufSize+100)
serverConn, _ := proxyFromCkServerL.Accept() serverConn, _ := proxyFromCkServerL.Accept()
for { for {
@ -538,6 +539,7 @@ func BenchmarkThroughput(b *testing.B) {
<-more <-more
} }
}() }()
// receiver
clientConn, _ := proxyToCkClientD.Dial("", "") clientConn, _ := proxyToCkClientD.Dial("", "")
readBuf := make([]byte, bufSize) readBuf := make([]byte, bufSize)
clientConn.Write([]byte{1}) // to make server accept clientConn.Write([]byte{1}) // to make server accept
@ -545,6 +547,7 @@ func BenchmarkThroughput(b *testing.B) {
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
io.ReadFull(clientConn, readBuf) io.ReadFull(clientConn, readBuf)
// ask for more
more <- 0 more <- 0
} }
}) })

Loading…
Cancel
Save