realtime-multiplayer-in-html5 icon indicating copy to clipboard operation
realtime-multiplayer-in-html5 copied to clipboard

add server response time metrics

Open jgamedev opened this issue 8 years ago • 3 comments

As adding and removing functionality on the server will definitely impact response times - which is critical in a multiplayer game - it would be nice if there was a way to quickly see ( in the server console log, for instance) how many milliseconds it took for the server to process the request and return the response back to the client.

jgamedev avatar Jul 03 '16 17:07 jgamedev

Any suggestion on how to measure this?

arjanfrans avatar Jul 17 '16 12:07 arjanfrans

What I would do is the most simple thing possible which is to keep a timestamp before you run the game update logic and calculate the delta after it's done. The goal is to have a measure of how long it took the CPU to update the game state

var timeBefore = Date.now();
yourUpdateStateCallHere()
var delta = Date.now() - timeBefore;
console.log('Game state updated in %f ms', delta) 

jgamedev avatar Jul 17 '16 20:07 jgamedev

On the topic of benchmarking, found out about these 2 libs today: https://benchmarkjs.com/ https://github.com/wadey/node-microtime

I think the second one is more useful to timing single function execution.

jgamedev avatar Jul 31 '16 07:07 jgamedev