From 68eb6bb2825241f24bb0bb22308f3b716cb45596 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 14 Sep 2023 15:24:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=8E=8B=E6=B5=8B=E6=97=B6?= =?UTF-8?q?=E9=95=BF=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/robot/statisticalcomp.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/robot/statisticalcomp.go b/modules/robot/statisticalcomp.go index 5d7c773b6..c8b08b5ea 100644 --- a/modules/robot/statisticalcomp.go +++ b/modules/robot/statisticalcomp.go @@ -20,6 +20,8 @@ type statisticalComp struct { failclientNum int32 //链接失败客户端数 robotdata map[string][]*RobotStatistics //机器人统计数据 lock sync.RWMutex + start time.Time //开始时间 + end time.Time //结束时间 } //组件初始化接口 @@ -32,6 +34,7 @@ func (this *statisticalComp) Init(service core.IService, module core.IModule, co func (this *statisticalComp) Start() (err error) { err = this.ModuleCompBase.Start() + this.start = time.Now() go this.run() return } @@ -52,6 +55,7 @@ func (this *statisticalComp) RobotFinishedTest(robot *Robot) { this.robotdata[robot.Account()] = robot.statistics this.lock.Unlock() this.succclientNum++ + this.end = time.Now() } //输出报表 @@ -81,7 +85,8 @@ func (this *statisticalComp) OutReport() { file.WriteString(fmt.Sprintf("机器人总数: %d\n", this.module.options.RobotTotalNum)) file.WriteString(fmt.Sprintf("成功数量: %d\n", this.succclientNum)) file.WriteString(fmt.Sprintf("失败数量: %d\n", this.failclientNum)) - file.WriteString(fmt.Sprintf("消息总吞吐量: %d\n", totalmessage)) + file.WriteString(fmt.Sprintf("压测执行时长: %f秒\n", this.end.Sub(this.start).Seconds())) + file.WriteString(fmt.Sprintf("消息总请求数: %d\n", totalmessage)) file.WriteString("---消息压测详情----------------------------------------------------------------------------------------------------\n") for message, data := range messages { sort.Slice(data, func(i, j int) bool {