diff --git a/bin/压力测试报告001.txt b/bin/压力测试报告001.txt new file mode 100644 index 000000000..a9299f656 --- /dev/null +++ b/bin/压力测试报告001.txt @@ -0,0 +1,40 @@ +机器人总数: 3000 +成功数量: 2958 +失败数量: 0 +消息总吞吐量: 412945 +---消息压测详情---------------------------------------------------------------------------------------------------- +消息名:pagoda.getlist 请求次数:2500 耗时最小:13 ms 耗时最大:1118 ms 平均耗时:20.98ms 中位耗时:18.00ms +消息名:viking.challenge 请求次数:21005 耗时最小:15 ms 耗时最大:1254 ms 平均耗时:22.95ms 中位耗时:21.00ms +消息名:caravan.getstory 请求次数:4171 耗时最小:14 ms 耗时最大:1244 ms 平均耗时:19.95ms 中位耗时:19.00ms +消息名:equipment.getlist 请求次数:2741 耗时最小:13 ms 耗时最大:1117 ms 平均耗时:20.32ms 中位耗时:18.00ms +消息名:gm.cmd 请求次数:39556 耗时最小:13 ms 耗时最大:1493 ms 平均耗时:20.53ms 中位耗时:19.00ms +消息名:wtask.info 请求次数:2584 耗时最小:14 ms 耗时最大:1130 ms 平均耗时:22.66ms 中位耗时:19.00ms +消息名:caravan.gotocity 请求次数:21345 耗时最小:15 ms 耗时最大:1372 ms 平均耗时:26.34ms 中位耗时:20.00ms +消息名:hero.list 请求次数:2778 耗时最小:13 ms 耗时最大:1122 ms 平均耗时:23.79ms 中位耗时:18.00ms +消息名:arena.challengereward 请求次数:20809 耗时最小:17 ms 耗时最大:1321 ms 平均耗时:25.30ms 中位耗时:23.00ms +消息名:viking.challengeover 请求次数:20947 耗时最小:21 ms 耗时最大:1300 ms 平均耗时:30.06ms 中位耗时:28.00ms +消息名:user.login 请求次数:2958 耗时最小:22 ms 耗时最大:1026 ms 平均耗时:522.31ms 中位耗时:522.00ms +消息名:sys.funcgetlist 请求次数:2435 耗时最小:13 ms 耗时最大:1179 ms 平均耗时:24.73ms 中位耗时:18.00ms +消息名:equipment.upgrade 请求次数:21434 耗时最小:14 ms 耗时最大:1285 ms 平均耗时:24.99ms 中位耗时:20.00ms +消息名:wtask.completecondi 请求次数:4417 耗时最小:14 ms 耗时最大:1234 ms 平均耗时:20.66ms 中位耗时:19.00ms +消息名:pagoda.challengeover 请求次数:21053 耗时最小:19 ms 耗时最大:1297 ms 平均耗时:29.90ms 中位耗时:28.00ms +消息名:user.create 请求次数:2851 耗时最小:13 ms 耗时最大:922 ms 平均耗时:25.25ms 中位耗时:23.00ms +消息名:arena.info 请求次数:2560 耗时最小:13 ms 耗时最大:1084 ms 平均耗时:22.02ms 中位耗时:18.00ms +消息名:hero.drawcard 请求次数:21808 耗时最小:38 ms 耗时最大:2678 ms 平均耗时:68.35ms 中位耗时:64.00ms +消息名:shop.buy 请求次数:100 耗时最小:17 ms 耗时最大:102 ms 平均耗时:20.74ms 中位耗时:19.00ms +消息名:items.getlist 请求次数:2719 耗时最小:13 ms 耗时最大:939 ms 平均耗时:20.42ms 中位耗时:18.00ms +消息名:wtask.battlefinish 请求次数:4413 耗时最小:21 ms 耗时最大:1299 ms 平均耗时:29.44ms 中位耗时:27.00ms +消息名:horoscope.upgrade 请求次数:21352 耗时最小:16 ms 耗时最大:1368 ms 平均耗时:33.54ms 中位耗时:29.00ms +消息名:pagoda.challenge 请求次数:21364 耗时最小:14 ms 耗时最大:1252 ms 平均耗时:23.25ms 中位耗时:19.00ms +消息名:wtask.accept 请求次数:13213 耗时最小:13 ms 耗时最大:1334 ms 平均耗时:21.20ms 中位耗时:18.00ms +消息名:wtask.battlestart 请求次数:4425 耗时最小:14 ms 耗时最大:1259 ms 平均耗时:20.29ms 中位耗时:19.00ms +消息名:arena.matche 请求次数:21419 耗时最小:17 ms 耗时最大:1248 ms 平均耗时:29.43ms 中位耗时:23.00ms +消息名:shop.getlist 请求次数:2536 耗时最小:14 ms 耗时最大:1039 ms 平均耗时:22.75ms 中位耗时:19.00ms +消息名:arena.challenge 请求次数:20874 耗时最小:16 ms 耗时最大:1312 ms 平均耗时:24.37ms 中位耗时:22.00ms +消息名:chat.send 请求次数:21419 耗时最小:12 ms 耗时最大:71 ms 平均耗时:17.46ms 中位耗时:17.00ms +消息名:wtask.finish 请求次数:11049 耗时最小:14 ms 耗时最大:1314 ms 平均耗时:24.71ms 中位耗时:20.00ms +消息名:viking.getlist 请求次数:21385 耗时最小:12 ms 耗时最大:1297 ms 平均耗时:22.79ms 中位耗时:17.00ms +消息名:caravan.buyorsell 请求次数:21009 耗时最小:15 ms 耗时最大:1315 ms 平均耗时:22.01ms 中位耗时:20.00ms +消息名:hero.talentlist 请求次数:2778 耗时最小:12 ms 耗时最大:1243 ms 平均耗时:21.03ms 中位耗时:18.00ms +消息名:horoscope.info 请求次数:2480 耗时最小:13 ms 耗时最大:857 ms 平均耗时:19.79ms 中位耗时:17.00ms +消息名:caravan.getlist 请求次数:2458 耗时最小:15 ms 耗时最大:1685 ms 平均耗时:32.47ms 中位耗时:22.00ms diff --git a/modules/chat/api_send.go b/modules/chat/api_send.go index 35e1d848e..d48b4ee53 100644 --- a/modules/chat/api_send.go +++ b/modules/chat/api_send.go @@ -80,10 +80,10 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (errda if msg.Ctype == pb.ChatType_Text { //过滤敏感词 msg.Content = wordfilter.Replace(msg.Content, '*') } - go func() { + go func(_session comm.IUserSession) { this.module.modelChat.sendChatToWorld(msg, max_chat) - this.module.ModuleBuried.TriggerBuried(session.Clone(), comm.GetBuriedParam(comm.Rtype62, 1)) - }() + this.module.ModuleBuried.TriggerBuried(_session, comm.GetBuriedParam(comm.Rtype62, 1)) + }(session.Clone()) break case pb.ChatChannel_Union: if msg.Ctype == pb.ChatType_Text { //过滤敏感词 diff --git a/modules/passon/module.go b/modules/passon/module.go index adeef5033..c80fd9477 100644 --- a/modules/passon/module.go +++ b/modules/passon/module.go @@ -9,6 +9,7 @@ import ( "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" + cfg "go_dreamfactory/sys/configure/structs" ) const moduleName = "传功塔" @@ -55,12 +56,13 @@ func (this *Passon) Start() (err error) { // 英雄升级 func (this *Passon) HeroUpLv(session comm.IUserSession, heroid string, lv int32) { var ( - passon *pb.DBPasson - heros []*pb.DBHero - change map[string]bool = make(map[string]bool) - maxlv int32 - errdata *pb.ErrorData - err error + passon *pb.DBPasson + heros []*pb.DBHero + change map[string]bool = make(map[string]bool) + maxlv int32 + errdata *pb.ErrorData + conf_i, conf_j *cfg.GameHeroData + err error ) if passon, err = this.modelPasson.getUserPasson(session.GetUserId()); err != nil { this.Error("getUserPasson err", log.Field{Key: "err", Value: err.Error()}) @@ -82,8 +84,14 @@ func (this *Passon) HeroUpLv(session comm.IUserSession, heroid string, lv int32) if heros[i].Lv != heros[j].Lv { return heros[i].Lv > heros[j].Lv } else { - conf_i, _ := this.ModuleTools.GetHeroConfig(heros[i].HeroID) - conf_j, _ := this.ModuleTools.GetHeroConfig(heros[j].HeroID) + if conf_i, err = this.ModuleTools.GetHeroConfig(heros[i].HeroID); err != nil { + this.Errorln(err) + return false + } + if conf_j, err = this.ModuleTools.GetHeroConfig(heros[j].HeroID); err != nil { + this.Errorln(err) + return true + } return conf_i.Color > conf_j.Color } }) diff --git a/modules/practice/module.go b/modules/practice/module.go index cbd61ed69..566075e96 100644 --- a/modules/practice/module.go +++ b/modules/practice/module.go @@ -103,6 +103,7 @@ func (this *Practice) OnInstallComp() { func (this *Practice) AddItems(session comm.IUserSession, items map[string]int32, bPush bool) (errdata *pb.ErrorData) { var ( err error + conn *db.DBConn room *pb.DBPracticeRoom id []string ) @@ -134,7 +135,7 @@ func (this *Practice) AddItems(session comm.IUserSession, items map[string]int32 Full: make(map[int32]int32), Knapsack: make(map[string]*pb.DBPracticeRes), } - conn, err := db.Cross() + conn, err = db.Cross() if err != nil { this.Errorln(err) return @@ -142,6 +143,7 @@ func (this *Practice) AddItems(session comm.IUserSession, items map[string]int32 model := db.NewDBModel(comm.TablePandata, time.Hour, conn) if err = model.Get(session.GetUserId(), room); err != nil && err != mgo.MongodbNil { this.Errorln(err) + return } if err == mgo.MongodbNil { room = &pb.DBPracticeRoom{ diff --git a/modules/robot/statisticalcomp.go b/modules/robot/statisticalcomp.go index 3a37792a8..5d7c773b6 100644 --- a/modules/robot/statisticalcomp.go +++ b/modules/robot/statisticalcomp.go @@ -4,7 +4,6 @@ import ( "fmt" "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" - "go_dreamfactory/lego/sys/log" "os" "sort" "sync" @@ -19,7 +18,6 @@ type statisticalComp struct { module *RobotModule succclientNum int32 //链接成功客户端数 failclientNum int32 //链接失败客户端数 - totalmessage int32 //总消息两 robotdata map[string][]*RobotStatistics //机器人统计数据 lock sync.RWMutex } @@ -59,13 +57,14 @@ func (this *statisticalComp) RobotFinishedTest(robot *Robot) { //输出报表 func (this *statisticalComp) OutReport() { var ( - messages map[string][]int64 = make(map[string][]int64) - ok bool + messages map[string][]int64 = make(map[string][]int64) + totalmessage int32 + ok bool ) this.lock.Lock() for _, datas := range this.robotdata { for _, v := range datas { - this.totalmessage++ + totalmessage++ if _, ok = messages[v.message]; !ok { messages[v.message] = make([]int64, 0) } @@ -82,7 +81,7 @@ 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", this.totalmessage)) + file.WriteString(fmt.Sprintf("消息总吞吐量: %d\n", totalmessage)) file.WriteString("---消息压测详情----------------------------------------------------------------------------------------------------\n") for message, data := range messages { sort.Slice(data, func(i, j int) bool { @@ -103,7 +102,6 @@ func (this *statisticalComp) OutReport() { } file.WriteString(fmt.Sprintf("消息名:%-20s 请求次数:%-5d 耗时最小:%-5dms 耗时最大:%-5dms 平均耗时:%-5.2fms 中位耗时:%-5.2fms \n", message, len(data), min, max, avg, median)) } - log.Debugf("机器人报表已输出!") } func (this *statisticalComp) run() {