Reduced server CPU usage
This commit is contained in:
parent
2738895efe
commit
eb8ff40d7b
@ -15,13 +15,13 @@ func main() {
|
||||
server.SetHandler(packet.Login, game.Login)
|
||||
|
||||
// Show statistics
|
||||
last := time.Now()
|
||||
ticker := time.NewTicker(time.Second)
|
||||
|
||||
go func() {
|
||||
for {
|
||||
if time.Now().After(last.Add(time.Second)) {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
fmt.Printf("%d packets per second, %d clients\n", server.PacketCount(), game.Clients.Count())
|
||||
last = time.Now()
|
||||
server.ResetPacketCount()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user