diff --git a/modules/hero/module.go b/modules/hero/module.go index 6191b7e06..e333180c3 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -244,7 +244,7 @@ func (this *Hero) GetSpecifiedHero(session comm.IUserSession, heroConfId string, //Event-------------------------------------------------------------------------------------------------玩家离线 func (this *Hero) EventUserOffline(session comm.IUserSession) { err := this.modelHero.RemoveUserHeroInfo(session) - this.Debugf("EventUserOffline:%s err:%v", session, err) + this.Debugf("EventUserOffline:%s err:%v", session.ToString(), err) } // 批量创建多个英雄 diff --git a/modules/task/model_task.go b/modules/task/model_task.go index a335ad27a..04a86248d 100644 --- a/modules/task/model_task.go +++ b/modules/task/model_task.go @@ -12,6 +12,8 @@ import ( "github.com/pkg/errors" "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) type ModelTask struct { @@ -26,6 +28,9 @@ func (this *ModelTask) Init(service core.IService, module core.IModule, comp cor this.moduleTask = module.(*ModuleTask) this.EventApp = event_v2.NewApp() this.EventApp.Listen(comm.EventTaskChanged, this.doTaskHandle) + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) return } diff --git a/stress/server/statistics/statistics.go b/stress/server/statistics/statistics.go index c14fc1f5d..060257bb6 100644 --- a/stress/server/statistics/statistics.go +++ b/stress/server/statistics/statistics.go @@ -202,12 +202,13 @@ func calculateData(concurrent, processingTime, requestTime, maxTime, minTime, su // header 打印表头信息 func header() { - log.Infof("\n\n") + fmt.Printf("\n\n") // 打印的时长都为毫秒 总请数 - log.Infof("─────┬───────┬───────┬───────┬────────┬───────────┬───────────┬───────────┬────────┬─────────┬───────") - log.Infof(" 耗时│ 并发数│ 成功数│ 失败数 │ qps │最长耗时 ms │最短耗时 ms│平均耗时 ms│下载字节│ 字节每秒 │ 状态码") - log.Infof("─────┼───────┼───────┼───────┼────────┼───────────┼───────────┼───────────┼────────┼─────────┼───────") + fmt.Println("─────┬───────┬───────┬───────┬────────┬────────┬────────┬────────┬────────┬────────┬────────") + fmt.Println(" 耗时│ 并发数│ 成功数│ 失败数│ qps │最长耗时│最短耗时│平均耗时│下载字节│字节每秒│ 状态码") + fmt.Println("─────┼───────┼───────┼───────┼────────┼────────┼────────┼────────┼────────┼────────┼────────") return + } // table 打印表格 diff --git a/stress/stress.go b/stress/stress.go index c03b5a2b7..2a2121ce9 100644 --- a/stress/stress.go +++ b/stress/stress.go @@ -9,7 +9,6 @@ import ( "go_dreamfactory/stress/model" "go_dreamfactory/stress/server" "go_dreamfactory/stress/server/statistics" - "runtime" "strings" "time" ) @@ -76,14 +75,14 @@ type Options struct { //go:generate go build main.go func main() { - runtime.GOMAXPROCS(cpuNumber) + //runtime.GOMAXPROCS(cpuNumber) flag.Parse() statistics.InitLog() - concurrency = 1000 + concurrency = 10 totalNumber = 1 debugStr = "false" - requestURL = "ws://10.0.0.9:7891/gateway" + requestURL = "ws://10.0.0.85:7891/gateway" verify = "pb" if concurrency == 0 || totalNumber == 0 || (requestURL == "" && path == "") { fmt.Printf("示例: go run main.go -c 1 -n 1 -u https://www.baidu.com/ \n")