diff --git a/modules/mgolog/db_comp.go b/modules/mgolog/db_comp.go index 340b9c5d5..001954bd1 100644 --- a/modules/mgolog/db_comp.go +++ b/modules/mgolog/db_comp.go @@ -40,7 +40,7 @@ func (this *DB_Comp) Start() (err error) { } func (this *DB_Comp) run() { - timer := time.NewTicker(time.Second * 2) + timer := time.NewTicker(time.Second * 1) defer timer.Stop() for { select { diff --git a/modules/task/model_active.go b/modules/task/model_active.go index 046c9bb15..d51a450e4 100644 --- a/modules/task/model_active.go +++ b/modules/task/model_active.go @@ -7,6 +7,8 @@ import ( "go_dreamfactory/pb" "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) type ModelTaskActive struct { @@ -18,6 +20,10 @@ func (this *ModelTaskActive) Init(service core.IService, module core.IModule, co this.TableName = comm.TableTaskActive err = this.MCompModel.Init(service, module, comp, options) this.moduleTask = module.(*ModuleTask) + // 加索引 + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) return } @@ -62,7 +68,7 @@ func (this *ModelTaskActive) noReceiveTaskActive(uid string, taskTag comm.TaskTa list := []*pb.DBTaskActive{} if err := this.GetList(uid, &list); err != nil { this.moduleTask.Errorf("getUserActiveList err:%v", err) - return false,err + return false, err } for _, v := range list { if v.Tag == int32(taskTag) && v.Received == 0 { diff --git a/modules/user/model_user.go b/modules/user/model_user.go index 46e93ad64..e8a19e91c 100644 --- a/modules/user/model_user.go +++ b/modules/user/model_user.go @@ -122,7 +122,7 @@ func (this *ModelUser) updateUserAttr(uid string, data map[string]interface{}) e func (this *ModelUser) isLoginFirst(timestamp int64) bool { now := configure.Now() if timestamp == 0 || timestamp > now.Unix() { - this.module.Debugf("lastlogin time great now") + //this.module.Debugf("lastlogin time great now") return false } tt := time.Unix(timestamp, 0) diff --git a/stress/server/golink/websocket_link.go b/stress/server/golink/websocket_link.go index 8d5415465..149aca499 100644 --- a/stress/server/golink/websocket_link.go +++ b/stress/server/golink/websocket_link.go @@ -23,7 +23,7 @@ var ( ) func init() { - keepAlive = true + keepAlive = false } // WebSocket webSocket go link diff --git a/stress/server/statistics/statistics.go b/stress/server/statistics/statistics.go index 060257bb6..53ddbfcb3 100644 --- a/stress/server/statistics/statistics.go +++ b/stress/server/statistics/statistics.go @@ -145,12 +145,10 @@ func ReceivingResults(concurrent uint64, ch <-chan *model.RequestResults, wg *sy log.Infof("\n\n") log.Infof("************************* 结果 stat ****************************") - log.Infof("处理协程数量:", concurrent) + log.Infof("处理协程数量:%d", concurrent) // fmt.Println("处理协程数量:", concurrent, "程序处理总时长:", log("%.3f", float64(processingTime/concurrent)/1e9), "秒") - log.Infof("请求总数(并发数*请求数 -c * -n):", successNum+failureNum, "总请求时间:", - fmt.Sprintf("%.3f", float64(requestTime)/1e9), - "秒", "successNum:", successNum, "failureNum:", failureNum) + log.Infof(fmt.Sprintf("请求总数(并发数*请求数 -c * -n):%d, 总请求时间:%s,秒, successNum:%d,failureNum:%d", successNum+failureNum, fmt.Sprintf("%.3f", float64(requestTime)/1e9), successNum, failureNum)) printTop(requestTimeList) log.Infof("************************* 结果 end ****************************") log.Infof("\n\n") @@ -202,11 +200,11 @@ func calculateData(concurrent, processingTime, requestTime, maxTime, minTime, su // header 打印表头信息 func header() { - fmt.Printf("\n\n") + log.Infof("\n\n") // 打印的时长都为毫秒 总请数 - fmt.Println("─────┬───────┬───────┬───────┬────────┬────────┬────────┬────────┬────────┬────────┬────────") - fmt.Println(" 耗时│ 并发数│ 成功数│ 失败数│ qps │最长耗时│最短耗时│平均耗时│下载字节│字节每秒│ 状态码") - fmt.Println("─────┼───────┼───────┼───────┼────────┼────────┼────────┼────────┼────────┼────────┼────────") + log.Infof(" ─────┬───────┬───────┬───────┬────────┬────────┬────────┬────────┬────────┬────────┬────────") + log.Infof(" 耗时│ 并发数│ 成功数│ 失败数│ qps │最长耗时 │最短耗时│平均耗时│下载字节│字节每秒 │ 状态码") + log.Infof(" ─────┼───────┼───────┼───────┼────────┼────────┼────────┼────────┼────────┼────────┼────────") return } diff --git a/stress/stress.go b/stress/stress.go index 2a2121ce9..457f9f058 100644 --- a/stress/stress.go +++ b/stress/stress.go @@ -79,7 +79,7 @@ func main() { flag.Parse() statistics.InitLog() - concurrency = 10 + concurrency = 12 totalNumber = 1 debugStr = "false" requestURL = "ws://10.0.0.85:7891/gateway"