Reduced server CPU usage

This commit is contained in:
Eduard Urbach 2024-01-24 22:40:05 +01:00
parent 2738895efe
commit eb8ff40d7b
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0

View File

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