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

First call to ic() can take significant amounts of time in Pygame games, especially in debug mode #166

Open
StephenPeringer opened this issue Nov 19, 2023 · 0 comments

Comments

@StephenPeringer
Copy link

StephenPeringer commented Nov 19, 2023

I've just started using ic(), and I've noticed that in the right context, it takes a too long to run.

This is the code I used to measure execution times:

from time import time
from icecream import ic

start = time()
ic.format("")
end = time()
print(f"time: {end - start}")

I ran this code in two different Pygame games, each in both Run and Debug modes, all in PyCharm. One game is a "Hello, World!" game, and the other is a more fully developed arcade game. I ran them each several times. These are all typical results, in descending order of problematic:

Fuller game, Debug mode

time: 1.7278175354003906

Fuller game, Run mode

time: 0.3357973098754883

Hello, World!, Debug mode

time: 0.27829909324645996

Hello, World!, Run mode

time: 0.12203741073608398

This kind of lag only happens the first time ic() is called; further calls are in the range of 0.001s to 0.005s.
I understand from reading other bug reports that you're not focused on speed, but 1.7 seconds is too long to wait each time a developer tweaks something and starts the game up to test it.

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

No branches or pull requests

1 participant