Reb*_*jah 0 python performance pygame pygame2
Pygame 昨晚运行良好,现在 pygame.init() 函数与之前的瞬间相比需要大约 40 秒才能完成。
import pygame
import time
start = time.time()
pygame.init()
print(f"Runtime: {time.time() - start}")
Run Code Online (Sandbox Code Playgroud)
控制台结果:
"C:\Program Files\Python39\python.exe" "D:/Google Drive/CompSci/proj/Alien Invasion/test.py"
pygame 2.0.1 (SDL 2.0.14, Python 3.9.0)
Hello from the pygame community. https://www.pygame.org/contribute.html
Runtime: 40.15961766242981
Run Code Online (Sandbox Code Playgroud)
通常运行时应该几乎是即时的......
我在 Windows Defender 中排除了所有相关文件夹: Windows Defender 排除项
根据此 GitHub 问题,故障排除步骤是init单独执行所有操作,例如:
pygame.display.init()
pygame.mixer.pre_init(frequency=44100, size=-16, channels=2, buffersize=512,
allowedchanges=pygame.AUDIO_ALLOW_ANY_CHANGE)
pygame.mixer.init()
pygame.joystick.init()
Run Code Online (Sandbox Code Playgroud)
这将使您清楚哪个正在减慢速度。在 OP 的情况下,它joystick.init()导致了缓慢,这是通过断开并重新连接键盘来解决的。
| 归档时间: |
|
| 查看次数: |
58 次 |
| 最近记录: |