This commit is contained in:
meixiongfeng 2023-12-15 18:32:14 +08:00
commit 3a4e09a80d
4 changed files with 98 additions and 11 deletions

View File

@ -0,0 +1,45 @@
机器人总数: 3000
成功数量: 3000
失败数量: 0
压测执行时长: 3189.08秒
消息总请求数: 660838
---消息压测详情----------------------------------------------------------------------------------------------------
消息名:arena.info 请求次数:3000 耗时最小:14 ms 耗时最大:67 ms 平均耗时:19.87ms 中位耗时:20.00ms
消息名:shop.getlist 请求次数:3000 耗时最小:16 ms 耗时最大:48 ms 平均耗时:22.55ms 中位耗时:22.00ms
消息名:caravan.getlist 请求次数:3000 耗时最小:18 ms 耗时最大:72 ms 平均耗时:31.09ms 中位耗时:30.00ms
消息名:arena.challenge 请求次数:29162 耗时最小:17 ms 耗时最大:287 ms 平均耗时:25.42ms 中位耗时:25.00ms
消息名:chat.send 请求次数:29152 耗时最小:13 ms 耗时最大:278 ms 平均耗时:19.13ms 中位耗时:19.00ms
消息名:wtask.boxreceive 请求次数:1483 耗时最小:15 ms 耗时最大:38 ms 平均耗时:21.52ms 中位耗时:21.00ms
消息名:items.getlist 请求次数:3000 耗时最小:16 ms 耗时最大:66 ms 平均耗时:22.17ms 中位耗时:22.00ms
消息名:gm.cmd 请求次数:45000 耗时最小:14 ms 耗时最大:263 ms 平均耗时:20.81ms 中位耗时:20.00ms
消息名:hero.drawcard 请求次数:29199 耗时最小:47 ms 耗时最大:221 ms 平均耗时:80.24ms 中位耗时:80.00ms
消息名:pagoda.challenge 请求次数:29084 耗时最小:15 ms 耗时最大:279 ms 平均耗时:21.79ms 中位耗时:21.00ms
消息名:user.login 请求次数:3000 耗时最小:22 ms 耗时最大:1258 ms 平均耗时:527.71ms 中位耗时:525.50ms
消息名:wtask.finish 请求次数:35837 耗时最小:14 ms 耗时最大:149 ms 平均耗时:21.85ms 中位耗时:21.00ms
消息名:arena.matche 请求次数:29162 耗时最小:18 ms 耗时最大:290 ms 平均耗时:25.50ms 中位耗时:25.00ms
消息名:horoscope.upgrade 请求次数:29028 耗时最小:23 ms 耗时最大:278 ms 平均耗时:37.35ms 中位耗时:36.00ms
消息名:mainline.challenge 请求次数:13153 耗时最小:17 ms 耗时最大:273 ms 平均耗时:24.91ms 中位耗时:24.00ms
消息名:sys.funcgetlist 请求次数:3000 耗时最小:15 ms 耗时最大:59 ms 平均耗时:20.39ms 中位耗时:20.00ms
消息名:wtask.battlefinish 请求次数:10462 耗时最小:26 ms 耗时最大:5018 ms 平均耗时:36.42ms 中位耗时:34.00ms
消息名:caravan.buyorsell 请求次数:29028 耗时最小:18 ms 耗时最大:265 ms 平均耗时:26.34ms 中位耗时:25.00ms
消息名:hero.list 请求次数:3000 耗时最小:15 ms 耗时最大:243 ms 平均耗时:20.65ms 中位耗时:20.00ms
消息名:mainline.info 请求次数:3000 耗时最小:15 ms 耗时最大:51 ms 平均耗时:20.83ms 中位耗时:21.00ms
消息名:horoscope.info 请求次数:3000 耗时最小:13 ms 耗时最大:257 ms 平均耗时:19.05ms 中位耗时:19.00ms
消息名:mainline.levelpass 请求次数:27881 耗时最小:14 ms 耗时最大:272 ms 平均耗时:21.16ms 中位耗时:21.00ms
消息名:arena.challengereward 请求次数:29152 耗时最小:17 ms 耗时最大:394 ms 平均耗时:24.88ms 中位耗时:24.00ms
消息名:viking.challenge 请求次数:29152 耗时最小:18 ms 耗时最大:266 ms 平均耗时:24.75ms 中位耗时:24.00ms
消息名:caravan.gotocity 请求次数:29028 耗时最小:18 ms 耗时最大:281 ms 平均耗时:26.22ms 中位耗时:25.00ms
消息名:hero.talentlist 请求次数:3000 耗时最小:14 ms 耗时最大:63 ms 平均耗时:19.34ms 中位耗时:19.00ms
消息名:wtask.info 请求次数:3000 耗时最小:14 ms 耗时最大:40 ms 平均耗时:20.20ms 中位耗时:20.00ms
消息名:pagoda.getlist 请求次数:3000 耗时最小:14 ms 耗时最大:254 ms 平均耗时:20.15ms 中位耗时:20.00ms
消息名:wtask.accept 请求次数:38836 耗时最小:14 ms 耗时最大:259 ms 平均耗时:20.60ms 中位耗时:20.00ms
消息名:wtask.battlestart 请求次数:10472 耗时最小:14 ms 耗时最大:256 ms 平均耗时:21.53ms 中位耗时:21.00ms
消息名:viking.challengeover 请求次数:29084 耗时最小:27 ms 耗时最大:420 ms 平均耗时:36.96ms 中位耗时:35.00ms
消息名:user.create 请求次数:2999 耗时最小:20 ms 耗时最大:263 ms 平均耗时:25.90ms 中位耗时:25.00ms
消息名:wtask.completecondi 请求次数:14981 耗时最小:15 ms 耗时最大:252 ms 平均耗时:21.42ms 中位耗时:21.00ms
消息名:pagoda.challengeover 请求次数:29015 耗时最小:23 ms 耗时最大:5019 ms 平均耗时:35.87ms 中位耗时:34.00ms
消息名:mainline.challengeover 请求次数:13127 耗时最小:24 ms 耗时最大:421 ms 平均耗时:38.40ms 中位耗时:37.00ms
消息名:equipment.getlist 请求次数:3000 耗时最小:14 ms 耗时最大:248 ms 平均耗时:19.42ms 中位耗时:19.00ms
消息名:equipment.upgrade 请求次数:29199 耗时最小:16 ms 耗时最大:262 ms 平均耗时:22.84ms 中位耗时:22.00ms
消息名:viking.getlist 请求次数:29152 耗时最小:13 ms 耗时最大:273 ms 平均耗时:19.17ms 中位耗时:19.00ms
消息名:shop.buy 请求次数:10 耗时最小:15 ms 耗时最大:20 ms 平均耗时:16.20ms 中位耗时:16.00ms

View File

@ -45,8 +45,13 @@ func (this *ModuleRobot_MainLine) Receive(robot IRobot, stype string, message pr
this.info.Level = make(map[int32]int32) this.info.Level = make(map[int32]int32)
} }
break break
case "create": case "challengeover":
// resp := message.(*pb.UserCreateResp) resp := message.(*pb.MainlineChallengeOverResp)
this.info.Level[resp.Level] = resp.Star
break
case "levelpass":
resp := message.(*pb.MainlineLevelPassResp)
this.info.Level[resp.Level] = resp.Star
break break
} }
return return

View File

@ -79,6 +79,7 @@ func (this *ModuleRobot_WTask) Receive(robot IRobot, stype string, message proto
break break
case "acceptchange": case "acceptchange":
resp := message.(*pb.WTaskAcceptChangePush) resp := message.(*pb.WTaskAcceptChangePush)
// log.Debug("[机器人 WTask-AcceptChange]", log.Field{Key: "Account", Value: robot.Account()}, log.Field{Key: "Resp", Value: resp.String()})
this.progress = resp.Accepts this.progress = resp.Accepts
if this.info != nil { if this.info != nil {
this.info.Accepts = make([]int32, 0) this.info.Accepts = make([]int32, 0)
@ -87,6 +88,10 @@ func (this *ModuleRobot_WTask) Receive(robot IRobot, stype string, message proto
} }
} }
break break
case "boxchange":
resp := message.(*pb.WTaskBoxChangePush)
this.info.Boxs = resp.Boxs
break
} }
return return
} }
@ -134,7 +139,7 @@ locp:
switch comm.TaskType(cconf.Type) { switch comm.TaskType(cconf.Type) {
case comm.Rtype1, comm.Rtype14: case comm.Rtype1, comm.Rtype14:
module = comm.ModuleHero module = comm.ModuleHero
case comm.Rtype20001, comm.Rtype70, comm.Rtype227: case comm.Rtype20001, comm.Rtype70, comm.Rtype205, comm.Rtype227:
module = comm.ModuleWtask module = comm.ModuleWtask
case comm.Rtype149, comm.Rtype152: case comm.Rtype149, comm.Rtype152:
module = comm.ModulePractice module = comm.ModulePractice
@ -228,6 +233,22 @@ func (this *ModuleRobot_WTask) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskD
return return
} }
break break
case comm.Rtype205: //拾取宝箱
boxid := int32(0)
for k, v := range this.info.Boxs[taskconf.Key].Boxs {
if v == 0 {
boxid = k
break
}
}
if _, errdata = robot.SendTaskMessage(taskconf.Key, condconf.Id, "wtask", "boxreceive", &pb.WTaskBoxReceiveReq{
Tid: taskconf.Key,
Boxid: boxid,
}); errdata != nil {
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
return
}
break
} }
return return
} }

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/log"
"os" "os"
"sort" "sort"
"sync" "sync"
@ -18,6 +19,8 @@ type statisticalComp struct {
module *RobotModule module *RobotModule
succclientNum int32 //链接成功客户端数 succclientNum int32 //链接成功客户端数
failclientNum int32 //链接失败客户端数 failclientNum int32 //链接失败客户端数
curonlineNum int32 //当前在线人数
maxonlineNum int32 //最大在线人数
robotdata map[string][]*RobotStatistics //机器人统计数据 robotdata map[string][]*RobotStatistics //机器人统计数据
lock sync.RWMutex lock sync.RWMutex
start time.Time //开始时间 start time.Time //开始时间
@ -41,7 +44,12 @@ func (this *statisticalComp) Start() (err error) {
//添加成功客户端数 //添加成功客户端数
func (this *statisticalComp) AddSuccClient(robot *Robot) { func (this *statisticalComp) AddSuccClient(robot *Robot) {
this.lock.Lock()
this.curonlineNum++
if this.curonlineNum > this.maxonlineNum {
this.maxonlineNum = this.curonlineNum
}
this.lock.Unlock()
} }
//添加失败客户端数 //添加失败客户端数
@ -53,9 +61,10 @@ func (this *statisticalComp) AddFailClient(robot *Robot, err error) {
func (this *statisticalComp) RobotFinishedTest(robot *Robot) { func (this *statisticalComp) RobotFinishedTest(robot *Robot) {
this.lock.Lock() this.lock.Lock()
this.robotdata[robot.Account()] = robot.statistics this.robotdata[robot.Account()] = robot.statistics
this.lock.Unlock() this.curonlineNum--
this.succclientNum++ this.succclientNum++
this.end = time.Now() this.end = time.Now()
this.lock.Unlock()
} }
//输出报表 //输出报表
@ -82,11 +91,13 @@ func (this *statisticalComp) OutReport() {
return return
} }
defer file.Close() defer file.Close()
file.WriteString(fmt.Sprintf("机器人总数: %d\n", this.module.options.RobotTotalNum)) 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.succclientNum))
file.WriteString(fmt.Sprintf("失败数量: %d\n", this.failclientNum)) file.WriteString(fmt.Sprintf("失败数量: %d\n", this.failclientNum))
file.WriteString(fmt.Sprintf("压测执行时长: %.2f秒\n", this.end.Sub(this.start).Seconds())) file.WriteString(fmt.Sprintf("最大同时在线人数: %d\n", this.maxonlineNum))
file.WriteString(fmt.Sprintf("消息总请求数: %d\n", totalmessage)) file.WriteString(fmt.Sprintf("压测执行时长: %.2f秒\n", this.end.Sub(this.start).Seconds()))
file.WriteString(fmt.Sprintf("消息总请求数: %d\n", totalmessage))
file.WriteString(fmt.Sprintf("QPS: %.2f\n", float64(totalmessage)/this.end.Sub(this.start).Seconds()))
file.WriteString("---消息压测详情----------------------------------------------------------------------------------------------------\n") file.WriteString("---消息压测详情----------------------------------------------------------------------------------------------------\n")
for message, data := range messages { for message, data := range messages {
sort.Slice(data, func(i, j int) bool { sort.Slice(data, func(i, j int) bool {
@ -111,11 +122,16 @@ func (this *statisticalComp) OutReport() {
func (this *statisticalComp) run() { func (this *statisticalComp) run() {
timer := time.NewTicker(time.Second * 10) timer := time.NewTicker(time.Second * 10)
locp:
for { for {
select { select {
case <-timer.C: case <-timer.C:
this.OutReport() this.OutReport()
if this.failclientNum+this.succclientNum >= this.module.options.RobotTotalNum {
break locp
}
} }
} }
timer.Stop()
log.Debug("[机器人 WTask]")
} }