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