Clicker Eats A Lot Of Processor Time - Python 3
Solution 1:
Correct answer: I suspect a constant polling because of while True:
. Insert sleep or pyautogui.PAUSE there (inside while loop, before if
), if process sleeps for a while (even less then a second) it frees a lot of CPU cycles
Minor optimizations:
Also you're initializing entire User32.dll in every loop... twice (because of or
), it seems.
And User32 is HUGE
Hints and notes:
If I remember python rules right, you just can move hllDll
to a module level (above function defintion), get_space_state()
will find it anyway. Or you can pass it as a parameter. And you don't need to redefine VK_SPACE every function call - though this is a micro-optimization
If all these fixes won't work, you should use debuggers, to find a true source of slowdowns
If you happen to have problems like this in the future, use something like Immunity or WinDbg to attach to process and see what's going on there
Post a Comment for "Clicker Eats A Lot Of Processor Time - Python 3"