This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testing: warning: no tests to run | |
PASS | |
BenchmarkHttpSync 2 1040816732 ns/op | |
BenchmarkHttpAsync 1 1168044579 ns/op | |
BenchmarkTCPSync 1 1021137163 ns/op | |
BenchmarkTCPAsync 1 1125243129 ns/op |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
according to http://golang.org/ref/mem (especially the last example) | |
Will BenchmakTCP be guarantted to read tcpStarted = true next time? | |
Will server be guaranteed to Listen before client's Dial?? | |
func BenchmarkTCP(b *testing.B) { | |
done := make(chan bool, 10) | |
if !tcpStarted { | |
go startServer() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BenchmarkHttpSync 2 607772481 ns/op | |
BenchmarkHttpAsync 2 572791120 ns/op | |
BenchmarkTCPSync 2 572156303 ns/op | |
BenchmarkTCPAsync 2 566128710 ns/op | |
BenchmarkTcpDummySync 10 158858648 ns/op | |
BenchmarkHTTP 5 473381980 ns/op | |
BenchmarkTCP 10 134515019 ns/o |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
message { | |
msgType (func name) | |
param | |
result | |
} | |
client: | |
select { | |
case <-send(encode(message)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 * int64 and 1 * int32 | |
BenchmarkPreAcceptProtoMarshal 5000000 480 ns/op 220.38 MB/s | |
5 * int32 | |
BenchmarkPreAcceptProtoMarshal 5000000 584 ns/op 188.23 MB/s | |
repeated(slice) type | |
BenchmarkPreAcceptProtoMarshal 1000000 1282 ns/op 266.76 MB/s | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BenchmarkNoSerializedServer 10 154370813 ns/op | |
BenchmarkSerializedServer 10 234600748 ns/op | |
compared with original rpc: | |
BenchmarkHttpSync 2 591041878 ns/op | |
BenchmarkHttpAsync 2 595159969 ns/op | |
BenchmarkTCPSync 2 612891027 ns/op | |
BenchmarkTCPAsync 2 623569721 ns/op |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type A struct { | |
slice []int | |
} | |
a = &A{make([]int, 0)} | |
bytes, _ := a.Marshal() | |
b := new(A) // b.slice == nil | |
b.Unmarshal(bytes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const writeOp = 0x100 | |
const { | |
GET = iota | |
CONTAINS = iota | |
... | |
WRITE = writeOp | |
DELETE = writeOp + 1 | |
UPDATE = writeOP + 2 | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ go build testsplice.go | |
$ echo "hello splice" | ./testsplice | |
$ splicing... buffer size: 4096 | |
recv: hello splice | |
count: 13 | |
finish |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net" | |
"os" | |
"syscall" | |
"time" | |
) |
OlderNewer