MOS6502 模拟器跑 Atari2600 的两个游戏所得到的结果
测试环境是 Windows x64,Intel 2.8GHz
C 版本是从底下这儿来的
http://codegolf.stackexchange.com/questions/12844/emulate-a-mos-6502-cpu
Python 跟 RPython 版本都是 Py65 的修改版
结果如下
Python32 < Python64 < PyPy < PyPy3 < RPython O0 < C O0 < RPython O3 < C O3
最慢跟最快差了快 200 倍,比较需要注意的是 PyPy3 硬是比 PyPy 快了不少
Z:\>py -2.7-32 test.py
Filename: Alien.bin
Frequency: 3404332
Counter: 11076043
Second: 3.253514
Instruction: 1000000
Cycle: 3055614
MHz: 0.939173
Z:\>py -2.7-32 -O test.py
Filename: Alien.bin
Frequency: 3404332
Counter: 11018579
Second: 3.236635
Instruction: 1000000
Cycle: 3055614
MHz: 0.944071
Z:\>py -2.7-64 test.py
Filename: Alien.bin
Frequency: 3404332
Counter: 9756155
Second: 2.865806
Instruction: 1000000
Cycle: 3055614
MHz: 1.066232
Z:\>py -2.7-64 -O test.py
Filename: Alien.bin
Frequency: 3404332
Counter: 9849147
Second: 2.893122
Instruction: 1000000
Cycle: 3055614
MHz: 1.056165
Z:\>pypy test.py
Filename: Alien.bin
Frequency: 3404332
Counter: 259815659
Second: 76.319131
Instruction: 500000000
Cycle: 1527849101
MHz: 20.019215
Z:\>pypy -O test.py
Filename: Alien.bin
Frequency: 3404332
Counter: 259164404
Second: 76.127829
Instruction: 500000000
Cycle: 1527849101
MHz: 20.069522
Z:\>pypy3 test.py
Filename: Alien.bin
Frequency: 3404332
Counter: 134081417
Second: 39.385529
Instruction: 500000000
Cycle: 1527849101
MHz: 38.792144
Z:\>pypy3 -O test.py
Filename: Alien.bin
Frequency: 3404332
Counter: 137038840
Second: 40.254253
Instruction: 500000000
Cycle: 1527849101
MHz: 37.954974
Z:\>test-c