上传压测时长显示

This commit is contained in:
liwei1dao 2023-09-14 15:24:25 +08:00
parent d86fb743c0
commit 68eb6bb282

View File

@ -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 {