p5py / p5

p5 is a Python package based on the core ideas of Processing.
https://p5.readthedocs.io
GNU General Public License v3.0
736 stars 120 forks source link

Hit a performance issue when translating p5js code for Steering Behaviours #101

Open jeremy886 opened 5 years ago

jeremy886 commented 5 years ago

Is your feature request related to a problem? Please describe. I am taking an online course using p5js but I use Python. P5py was working well until I started to use it to simulate Steering Behaviours.

My code is here. Particularly flowfield.py and separation.py

The course is the Nature of Code.

Describe the solution you'd like If you check the javascript equivalent code, it performs really well. p5js Click Play

I know p5py is built on vispy so I downloaded a few examples and ran them. They seem okay and not as sluggish as p5py.

Here is a video for a quick examination: Click to see and the vispy example is on the left.

Describe alternatives you've considered I am considering testing it with PyQt or PySide2 as the backend for vispy but I think that p5py is using glfw.

I also use other tools (like arcade which is using pyglet) and it is also sluggish if I create too many moving objects.

But I still have some hope for vispy. I wonder if the javascript way of coding is problematic. I've sent the code to stackoverflow for comment.

Additional context My machine is 2018 Dell Alienware 17R4. (a powerful gaming laptop with Nvidia GeForce GTX 1080).

Environment:

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.
>>> import vispy
>>> print(vispy.sys_info())
Platform: Windows-10-10.0.17134-SP0
Python:   3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]
NumPy:    1.16.2
Backend:  Glfw
pyqt4:    None
pyqt5:    None
pyside:   None
pyglet:   None
glfw:     glfw (3, 2, 1)
sdl2:     None
wx:       None
egl:      None
osmesa:   None
_test:    None

GL version:  '4.6.0 NVIDIA 417.22'
MAX_TEXTURE_SIZE: 32768
Extensions: 'GL_AMD_multi_draw_indirect GL_AMD_seamless_cubemap_per_texture GL_AMD_vertex_sha...............

Is there an easy way to improve p5py's performance?

tushar5526 commented 2 years ago

Related to #293

tushar5526 commented 2 years ago

This now works fine with the new skia renderer. I have tested it.