tsak 创建索引

This commit is contained in:
meixiongfeng 2022-12-05 15:18:38 +08:00
parent 7ec319f40d
commit bf49318e8d
4 changed files with 14 additions and 9 deletions

View File

@ -244,7 +244,7 @@ func (this *Hero) GetSpecifiedHero(session comm.IUserSession, heroConfId string,
//Event-------------------------------------------------------------------------------------------------玩家离线 //Event-------------------------------------------------------------------------------------------------玩家离线
func (this *Hero) EventUserOffline(session comm.IUserSession) { func (this *Hero) EventUserOffline(session comm.IUserSession) {
err := this.modelHero.RemoveUserHeroInfo(session) err := this.modelHero.RemoveUserHeroInfo(session)
this.Debugf("EventUserOffline:%s err:%v", session, err) this.Debugf("EventUserOffline:%s err:%v", session.ToString(), err)
} }
// 批量创建多个英雄 // 批量创建多个英雄

View File

@ -12,6 +12,8 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"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 ModelTask struct { type ModelTask struct {
@ -26,6 +28,9 @@ func (this *ModelTask) Init(service core.IService, module core.IModule, comp cor
this.moduleTask = module.(*ModuleTask) this.moduleTask = module.(*ModuleTask)
this.EventApp = event_v2.NewApp() this.EventApp = event_v2.NewApp()
this.EventApp.Listen(comm.EventTaskChanged, this.doTaskHandle) 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 return
} }

View File

@ -202,12 +202,13 @@ func calculateData(concurrent, processingTime, requestTime, maxTime, minTime, su
// header 打印表头信息 // header 打印表头信息
func header() { func header() {
log.Infof("\n\n") fmt.Printf("\n\n")
// 打印的时长都为毫秒 总请数 // 打印的时长都为毫秒 总请数
log.Infof("─────┬───────┬───────┬───────┬────────┬──────────────────────┬───────────┬────────┬─────────┬───────") fmt.Println("─────┬───────┬───────┬───────┬────────┬────────┬────────┬────────┬────────┬────────┬───────")
log.Infof(" 耗时│ 并发数│ 成功数│ 失败数 │ qps │最长耗时 ms │最短耗时 ms│平均耗时 ms│下载字节│ 字节每秒 │ 状态码") fmt.Println(" 耗时│ 并发数│ 成功数│ 失败数 qps │最长耗时│最短耗时│平均耗时│下载字节│字节每秒│ 状态码")
log.Infof("─────┼───────┼───────┼───────┼────────┼──────────────────────┼───────────┼────────┼─────────┼───────") fmt.Println("─────┼───────┼───────┼───────┼────────┼────────┼────────┼────────┼────────┼────────┼───────")
return return
} }
// table 打印表格 // table 打印表格

View File

@ -9,7 +9,6 @@ import (
"go_dreamfactory/stress/model" "go_dreamfactory/stress/model"
"go_dreamfactory/stress/server" "go_dreamfactory/stress/server"
"go_dreamfactory/stress/server/statistics" "go_dreamfactory/stress/server/statistics"
"runtime"
"strings" "strings"
"time" "time"
) )
@ -76,14 +75,14 @@ type Options struct {
//go:generate go build main.go //go:generate go build main.go
func main() { func main() {
runtime.GOMAXPROCS(cpuNumber) //runtime.GOMAXPROCS(cpuNumber)
flag.Parse() flag.Parse()
statistics.InitLog() statistics.InitLog()
concurrency = 1000 concurrency = 10
totalNumber = 1 totalNumber = 1
debugStr = "false" debugStr = "false"
requestURL = "ws://10.0.0.9:7891/gateway" requestURL = "ws://10.0.0.85:7891/gateway"
verify = "pb" verify = "pb"
if concurrency == 0 || totalNumber == 0 || (requestURL == "" && path == "") { if concurrency == 0 || totalNumber == 0 || (requestURL == "" && path == "") {
fmt.Printf("示例: go run main.go -c 1 -n 1 -u https://www.baidu.com/ \n") fmt.Printf("示例: go run main.go -c 1 -n 1 -u https://www.baidu.com/ \n")