From 5f3b37e9784dd036973fc89782a523a84b770d6e Mon Sep 17 00:00:00 2001 From: Sydonian <794346190@qq.com> Date: Thu, 26 Sep 2024 14:39:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/internal/grpc/io.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/agent/internal/grpc/io.go b/agent/internal/grpc/io.go index 89eccbe..84b61ae 100644 --- a/agent/internal/grpc/io.go +++ b/agent/internal/grpc/io.go @@ -6,6 +6,7 @@ import ( "io" "time" + "github.com/inhies/go-bytesize" "gitlink.org.cn/cloudream/common/pkgs/ioswitch/exec" "gitlink.org.cn/cloudream/common/pkgs/logger" "gitlink.org.cn/cloudream/common/utils/io2" @@ -147,6 +148,7 @@ func (s *Service) GetStream(req *agtrpc.GetStreamReq, server agtrpc.Agent_GetStr buf := make([]byte, 1024*64) readAllCnt := 0 + startTime := time.Now() for { readCnt, err := reader.Read(buf) @@ -167,10 +169,11 @@ func (s *Service) GetStream(req *agtrpc.GetStreamReq, server agtrpc.Agent_GetStr // 文件读取完毕 if err == io.EOF { + dt := time.Since(startTime) logger. WithField("PlanID", req.PlanID). WithField("VarID", req.VarID). - Debugf("send data size %d", readAllCnt) + Debugf("send data size %d in %v, speed %v/s", readAllCnt, dt, bytesize.New(float64(readAllCnt)/dt.Seconds())) // 发送EOF消息 server.Send(&agtrpc.StreamDataPacket{ Type: agtrpc.StreamDataPacketType_EOF,