日志优化
This commit is contained in:
parent
dc5e730ffa
commit
087eabc12c
2
.gitignore
vendored
2
.gitignore
vendored
@ -27,3 +27,5 @@ src/server/unit_test/*.exe*
|
||||
src/server/unit_test/log*
|
||||
src/server/msg/meowmentnet
|
||||
src/server/.github/agents/merge2-server-lead.agent.md
|
||||
src/server/runtime/*
|
||||
src/server/unit_test/runtime/*
|
||||
|
||||
@ -1,64 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"server/game"
|
||||
"server/game/mod/msg"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// func TestBenchInit(t *testing.T) {
|
||||
// f := "wmz00%d"
|
||||
// for i := 0; i < 10000; i++ {
|
||||
// UserName := fmt.Sprintf(f, i)
|
||||
// game.G_GameLogicPtr.Db_AccountInfo.UserName = UserName
|
||||
// game.G_GameLogicPtr.Db_AccountInfo.UserPassword = "123456"
|
||||
// if game.G_GameLogicPtr.NewAccountInsertDataToDB() {
|
||||
// fmt.Printf("UserName:%s\n init success", UserName)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/*
|
||||
*
|
||||
cluster 消息处理基准测试
|
||||
|
||||
36716 34961 ns/op 1690 B/op 38 allocs/op
|
||||
*/
|
||||
func BenchmarkClusterMsg(b *testing.B) {
|
||||
game.ClusterMgrInit()
|
||||
runtime.GOMAXPROCS(8)
|
||||
game.G_getGameLogic()
|
||||
for i := 0; i < b.N; i++ {
|
||||
m := &msg.Msg{
|
||||
HandleType: msg.HANDLE_MOD_PLAYER_LOGIN,
|
||||
Extra: 0,
|
||||
}
|
||||
game.MessageHandle(m)
|
||||
}
|
||||
}
|
||||
|
||||
func printMemUsage() {
|
||||
var m runtime.MemStats
|
||||
runtime.ReadMemStats(&m)
|
||||
// 输出内存使用情况
|
||||
fmt.Printf("Alloc = %v MiB", bToMb(m.Alloc))
|
||||
fmt.Printf("\tTotalAlloc = %v MiB", bToMb(m.TotalAlloc))
|
||||
fmt.Printf("\tSys = %v MiB", bToMb(m.Sys))
|
||||
fmt.Printf("\tNumGC = %v\n", m.NumGC)
|
||||
var playerCount int
|
||||
game.G_GameLogicPtr.M_Players.Range(func(key, value interface{}) bool {
|
||||
playerCount++
|
||||
return true
|
||||
})
|
||||
fmt.Printf("\tPlayerNum = %v\n", playerCount)
|
||||
}
|
||||
|
||||
func bToMb(b uint64) uint64 {
|
||||
return b / 1024 / 1024
|
||||
}
|
||||
|
||||
func BenchmarkChampionshipGroup(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
game.G_GameLogicPtr.CreateChampshipMgr()
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
"TCPAddr": ":3601",
|
||||
"WSAddr": ":3567",
|
||||
"RPCAddr": ":50051",
|
||||
"MySqlAddr": "127.0.0.1",
|
||||
"MySqlAddr": "mysql",
|
||||
"MySqlPort": "3306",
|
||||
"MySqlUsr": "root",
|
||||
"MySqlPwd": "IOagNEq3C84c-20CmHEin5iODVc=",
|
||||
@ -24,7 +24,7 @@
|
||||
"ServerName": "Merge_Pet",
|
||||
"ServerStatus" : 1,
|
||||
"ServerCenter" : 0,
|
||||
"GameConfPath": "D:/Github/pet_home_server/src/server/gamedata/config/",
|
||||
"GameConfPath": "/data/pet_home_server/src/server/gamedata/config/",
|
||||
|
||||
"ListenAddr":":9002",
|
||||
"CenterAddr": "127.0.0.1:7000",
|
||||
@ -34,8 +34,8 @@
|
||||
"RedisPort" :"6379",
|
||||
"RedisPwd" :"",
|
||||
|
||||
"RedisWriteAddr":"127.0.0.1:6379",
|
||||
"RedisReadAddrs":"127.0.0.1:6379",
|
||||
"RedisWriteAddr":"redis:6379",
|
||||
"RedisReadAddrs":"redis:6379",
|
||||
"RedisMasterName":"mymaster",
|
||||
"RedisConnType":"Direct",
|
||||
|
||||
|
||||
@ -273,6 +273,10 @@ func (p *PlayerChessData) HandleChess(player *Player, handle_list []*msg.ChessHa
|
||||
ActItem := player.GetActivityItem(GoUtil.Int32ToInt(v.ActType))
|
||||
itemList = item.Merge(itemList, ActItem)
|
||||
case msg.HANDLE_TYPE_Remove: //移除棋子
|
||||
player.TeLog("remove_chess", map[string]interface{}{
|
||||
"chess_id": chessId,
|
||||
"chess_name": mergeDataCfg.GetNameById(chessId),
|
||||
})
|
||||
ChessMod.RemoveChess(chessId)
|
||||
}
|
||||
|
||||
|
||||
@ -375,10 +375,3 @@ func UnitCatnip(p *Player) error {
|
||||
fmt.Printf("buf len:%dk\n", buf.Len()/1024)
|
||||
return nil
|
||||
}
|
||||
|
||||
func Benchmark(player *Player) {
|
||||
ChampshipMod := player.PlayMod.getChampshipMod()
|
||||
ChampshipMod.AddScore([]int{949, 941, 10})
|
||||
player.HandleInChampshipRank()
|
||||
player.HandleInUserRank()
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user