日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

mac运行python速度慢_python-3.x – Pygame简单循环在Mac上运行得非常慢

發(fā)布時間:2023/12/19 python 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mac运行python速度慢_python-3.x – Pygame简单循环在Mac上运行得非常慢 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

E:在OS X和

Linux上測試相同后,我可以確認以下內(nèi)容只發(fā)生在OS X上.在Linux上,它實際上以千fps運行,因為我碰巧想知道.任何解釋?感謝TextMate,我更喜歡在Mac上進行開發(fā).

這是一個幾乎沒有任何作用的簡單循環(huán),并且運行速度非常慢.有人可以解釋為什么嗎FPS平均值略高于30,每次通過循環(huán)需要30多分鐘.窗口大小似乎根本不會影響這一點,因為即使設置像(50,50)這樣的小窗口大小也具有相同的fps.

我發(fā)現(xiàn)這很奇怪,我希望任何現(xiàn)代硬件都可以為這樣一個簡單的循環(huán)做一千fps,即使我們每次都更新每個像素.從配置文件中我可以看到{內(nèi)置方法get}和{內(nèi)置方法更新}組合似乎每次調(diào)用大約需要30ms的時間,這是否真的是我們可以在不使用臟的情況下獲得的最佳效果?

pygame.init()

clock = pygame.time.Clock()

fps = 1000

#milliseconds from last frame

new_time, old_time = None, None

done = False

while not done:

clock.tick(fps)

for event in pygame.event.get():

if event.type == pygame.QUIT:

done = True

# show fps and milliseconds

if new_time:

old_time = new_time

new_time = pygame.time.get_ticks()

if new_time and old_time:

pygame.display.set_caption("fps: " + str(int(clock.get_fps())) + " ms: " + str(new_time-old_time))

pygame.display.update()

這是主要功能的cProfile的開頭.

94503 function calls (92211 primitive calls) in 21.011 seconds

Ordered by: cumulative time

ncalls tottime percall cumtime percall filename:lineno(function)

1 0.026 0.026 21.011 21.011 new_main.py:34(main)

652 14.048 0.022 14.048 0.022 {built-in method get}

652 5.864 0.009 5.864 0.009 {built-in method update}

1 0.444 0.444 0.634 0.634 {built-in method init}

651 0.278 0.000 0.278 0.000 {built-in method set_caption}

72/1 0.000 0.000 0.151 0.151 :2234(_find_and_load)

72/1 0.000 0.000 0.151 0.151 :2207(_find_and_load_unlocked)

71/1 0.000 0.000 0.151 0.151 :1186(_load_unlocked)

46/1 0.000 0.000 0.151 0.151 :1122(_exec)

46/1 0.000 0.000 0.151 0.151 :1465(exec_module)

74/1 0.000 0.000 0.151 0.151 :313(_call_with_frames_removed)

54/1 0.004 0.000 0.151 0.151 {built-in method exec}

1 0.000 0.000 0.151 0.151 macosx.py:1()

1 0.000 0.000 0.150 0.150 pkgdata.py:18()

25/3 0.000 0.000 0.122 0.041 :1156(_load_backward_compatible)

8/1 0.026 0.003 0.121 0.121 {method 'load_module' of 'zipimport.zipimporter' objects}

1 0.000 0.000 0.101 0.101 __init__.py:15()

1 0.000 0.000 0.079 0.079 config_reader.py:115(build_from_config)

2 0.000 0.000 0.056 0.028 common.py:43(reset_screen)

2 0.055 0.027 0.055 0.027 {built-in method set_mode}

72/71 0.001 0.000 0.045 0.001 :2147(_find_spec)

70/69 0.000 0.000 0.043 0.001 :1934(find_spec)

70/69 0.001 0.000 0.043 0.001 :1902(_get_spec)

92 0.041 0.000 0.041 0.000 {built-in method load_extended}

6 0.000 0.000 0.041 0.007 new_map.py:74(add_character)

6 0.000 0.000 0.041 0.007 new_character.py:32(added_to_map)

6 0.001 0.000 0.041 0.007 new_character.py:265(__init__)

1 0.000 0.000 0.038 0.038 macosx.py:14(Video_AutoInit)

1 0.038 0.038 0.038 0.038 {built-in method InstallNSApplication}

1 0.036 0.036 0.036 0.036 {built-in method quit}

65 0.001 0.000 0.036 0.001 re.py:277(_compile)

49 0.000 0.000 0.036 0.001 re.py:221(compile)

總結(jié)

以上是生活随笔為你收集整理的mac运行python速度慢_python-3.x – Pygame简单循环在Mac上运行得非常慢的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。