p5 icon indicating copy to clipboard operation
p5 copied to clipboard

very slow when drawing a large number of points in a draw() function

Open SvineruS opened this issue 5 years ago • 5 comments

Describe the bug when trying to fill the canvas with pixels using a loop, the application is VERY slow.

To Reproduce

def draw():
    for x in range(s):
        for y in range(s):
            fill(some_different_colors)
            point(x, y)

in my case s = 20 also slow with circle and rect func

System information:

  • p5 release (version number or latest commit): 000b562
  • Python version: 3.7
  • Operating system: kubuntu 19.04

update: same performance using

  • p5 release (version number or latest commit): 0.6.0
  • Python version: 3.8
  • Operating system: manjaro

SvineruS avatar May 20 '19 22:05 SvineruS

We've noticed this issue as well, and we'll try to address this over the summer.

abhikpal avatar May 27 '19 12:05 abhikpal

Seeing similar sluggish performance in draw() on a 2019 Macbook Pro.

pikeas avatar Oct 15 '19 23:10 pikeas

First, I really enjoy p5. p5 is about 3 times as slow as Processing (python mode) when executing:

for k in range (len (circleList)): ellipse ( (200+2*k, circleList[k]), 5, 5)

where circleList is a list of 250 y coordinates. The code is executed on every frame.

I am using Python 3.8.2. The code is from "Math Adventures with Python", generating a sine wave from a small circle travelling on the circumference of a large circle. I also imported p5 using pypy3, but the execution time is the same. I am using a 4.5 GHz I6600k processor.

doug719 avatar May 03 '20 15:05 doug719

I have the same performance problem with the line function I use line to make a gradient on background, something like

for y in range(height):
  stroke(y/height*255, 80,255*(1-y/height))
  line(0,y,width,y)

not only is it slow, but the same code with p5.js in firefox (javascript in the not fastest browser for it) is three to four time more quick. openGl could theorically handle this very easely. Tens of thousands of polygons can normally be drawn in a second. Is vispy the problem ?

swirly avatar Sep 30 '21 05:09 swirly

#293 will fix this

tushar5526 avatar Jul 16 '22 21:07 tushar5526