This commit is contained in:
meixiongfeng 2022-12-05 16:09:13 +08:00
parent dece4b19b2
commit 71875d7312
6 changed files with 17 additions and 13 deletions

View File

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

View File

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

View File

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

View File

@ -23,7 +23,7 @@ var (
)
func init() {
keepAlive = true
keepAlive = false
}
// WebSocket webSocket go link

View File

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

View File

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