From f01d4cbb4c4363cfef093f21de4a72854255b6e0 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Sun, 18 Jul 2021 19:26:51 +0800 Subject: [PATCH] Test: add direct benchmark --- test/clash_test.go | 8 +++++++- test/docker_test.go | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/clash_test.go b/test/clash_test.go index 97f6648b..7d373bbd 100644 --- a/test/clash_test.go +++ b/test/clash_test.go @@ -15,6 +15,7 @@ import ( "testing" "time" + "github.com/Dreamacro/clash/adapter/outbound" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/hub/executor" "github.com/Dreamacro/clash/transport/socks5" @@ -70,7 +71,7 @@ func init() { } } - c, err := client.NewClientWithOpts(client.FromEnv) + c, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) if err != nil { panic(err) } @@ -668,3 +669,8 @@ log-level: silent time.Sleep(waitTime) testPingPongWithSocksPort(t, 10000) } + +func Benchmark_Direct(b *testing.B) { + proxy := outbound.NewDirect() + benchmarkProxy(b, proxy) +} diff --git a/test/docker_test.go b/test/docker_test.go index ce4c2de4..12c427b1 100644 --- a/test/docker_test.go +++ b/test/docker_test.go @@ -11,7 +11,7 @@ import ( var isDarwin = false func startContainer(cfg *container.Config, hostCfg *container.HostConfig, name string) (string, error) { - c, err := client.NewClientWithOpts(client.FromEnv) + c, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) if err != nil { return "", err } @@ -34,7 +34,7 @@ func startContainer(cfg *container.Config, hostCfg *container.HostConfig, name s } func cleanContainer(id string) error { - c, err := client.NewClientWithOpts(client.FromEnv) + c, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) if err != nil { return err }