Chore: benchmark explanation

This commit is contained in:
gVisor bot 2021-07-22 00:01:11 +08:00
parent 4e38de95f2
commit 2aaefba4e3
2 changed files with 13 additions and 2 deletions

View file

@ -47,3 +47,13 @@ Prerequisite
```
$ go test -p 1 -v
```
benchmark (Linux)
> Cannot represent the throughput of the protocol on your machine
> but you can compare the corresponding throughput of the protocol on clash
> (change chunkSize to measure the maximum throughput of clash on your machine)
```
$ go test -benchmem -run=^$ -bench .
```

View file

@ -636,7 +636,8 @@ func benchmarkProxy(b *testing.B, proxy C.ProxyAdapter) {
c.Close()
}()
chunk := make([]byte, 1024)
chunkSize := int64(16 * 1024)
chunk := make([]byte, chunkSize)
conn, err := proxy.DialContext(context.Background(), &C.Metadata{
Host: localIP.String(),
DstPort: "10001",
@ -646,7 +647,7 @@ func benchmarkProxy(b *testing.B, proxy C.ProxyAdapter) {
assert.FailNow(b, err.Error())
}
b.SetBytes(1024)
b.SetBytes(chunkSize)
b.ResetTimer()
for i := 0; i < b.N; i++ {
if _, err := conn.Write(chunk); err != nil {