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

pong CPU usage #24

Closed
cammarosano opened this issue Aug 31, 2022 · 2 comments
Closed

pong CPU usage #24

cammarosano opened this issue Aug 31, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@cammarosano
Copy link
Collaborator

id = setInterval(() => game.draw(), 0);

@BeBel42, this line is evil!
As you probably know, this (0 ms) is what tells to browser to re-render the canvas as fast as it can. And CPU usage goes up to the skies...
if you set it to 10 ms, in theory, you already get a 100 fps refresh rate (should be enough for pong, right?)
Anyway, this is no bug, but I think being easier on the cpu would be a nice enhancement.

@cammarosano cammarosano added the enhancement New feature or request label Aug 31, 2022
@BeBel42
Copy link
Collaborator

BeBel42 commented Aug 31, 2022

@dbanziziki Was the one who wrote that line 😅 But it was previously set to something like 100 I think? And it was laggy as hell... But if 10 seems good, then yeah, we can change this. I'll do it. We might as well use that remaining cpu for some bitcoin mining. Right? 😉

@BeBel42
Copy link
Collaborator

BeBel42 commented Aug 31, 2022

Done and tested it. (just in case). Closing the issue now.

@BeBel42 BeBel42 closed this as completed Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants