realtime-multiplayer-in-html5
realtime-multiplayer-in-html5 copied to clipboard
add server response time metrics
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.
Any suggestion on how to measure this?
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)
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.