Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add server response time metrics #8

Open
jgamedev opened this issue Jul 3, 2016 · 3 comments
Open

add server response time metrics #8

jgamedev opened this issue Jul 3, 2016 · 3 comments

Comments

@jgamedev
Copy link

jgamedev commented Jul 3, 2016

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.

@arjanfrans
Copy link
Owner

Any suggestion on how to measure this?

@jgamedev
Copy link
Author

jgamedev commented Jul 17, 2016

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants