diff --git a/test/README.md b/test/README.md index dec9999c..823fc544 100644 --- a/test/README.md +++ b/test/README.md @@ -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 . +``` diff --git a/test/clash_test.go b/test/clash_test.go index 7d373bbd..366cc260 100644 --- a/test/clash_test.go +++ b/test/clash_test.go @@ -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 {