@ wrote... (5 years, 11 months ago)

For funsies I ported my mazesolver to pypy.

See update 2 for reference.

It wasn't particularly hard, I just had to rip out numpy and just use straight lists.

And I got interesting results…

Here is cpython vs pypy. This is on different hardware so previous times in previous posts don't really apply.

CPython

$ time ./mazesolver.py mazes/4000x4000.png
loading: mazes/4000x4000.png
load_maze took 10.003s
find_entrance took 0ms
maze size: (4001, 4001) entrance at: (0, 1)
solving...
_find_exit took 158.351s
backtrack took 16.771s
exit at (4000, 3999), path length 783734
saving solved.png
save_map took 16.823s
main took 211.738s

real    3m31.907s
user    3m31.331s
sys 0m0.563s

PyPy

$ time ./mazesolver.py mazes/4000x4000.png
loading: mazes/4000x4000.png
load_maze took 116.407s
find_entrance took 0ms
maze size: (4001, 4001) entrance at: (0, 1)
solving...
_find_exit took 4.203s
backtrack took 2.172s
exit at (4000, 3999), path length 783734
saving solved.png
save_map took 128.890s
main took 254.144s

real    4m14.250s
user    4m12.355s
sys 0m1.872s

Results

The actual solving is 37 times faster. That's nothing to sneeze at but the PIL image parsing when loading is 11 times slower. And total time is 20% slower.

This seems to match the bug at: https://bugs.pypy.org/issue1201

Category: tech, Tags: mazes, python
Comments: 0
Click here to add a comment