我在pygame中运行一个小游戏,在主循环的每次迭代之间需要一个恒定的延迟。虽然我把FPS数锁定在60pygame.Clock.tick\u busy\u循环(),我观察到延迟的变化(每个循环大约4毫秒)。我的一个函数应该被窃听,但我很难找到哪一个。你知道吗
我在Ipython的主循环中使用了一个%prun,结果如下:2264 function calls in 5.439 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
322 4.401 0.014 4.401 0.014 {method 'tick' of 'Clock' objects}
322 0.730 0.002 0.730 0.002 {pygame.display.flip}
1 0.228 0.228 0.228 0.228 {pygame.base.quit}
1 0.034 0.034 0.034 0.034 {method 'blit' of 'pygame.Surface' objects}
1 0.028 0.028 5.439 5.439 main.py:9(main)
323 0.014 0.000 0.014 0.000 {pygame.event.get}
323 0.002 0.000 0.016 0.000 lib.py:26(getInput)
322 0.001 0.000 0.036 0.000 lib.py:80(checkEventType)
322 0.001 0.000 0.035 0.000 lib.py:91(instructions)
322 0.000 0.000 0.000 0.000 {method 'get_time' of 'Clock' objects}
1 0.000 0.000 5.439 5.439 :1()
1 0.000 0.000 0.000 0.000 {pygame.mixer.stop}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
2 0.000 0.000 0.000 0.000 {ord}
这里有什么可以解释每次迭代之间延迟2-5毫秒的变化吗?你知道吗