We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Slowlyness of processing
Page Index Toggle Pages: 1
Slowlyness of processing (Read 1243 times)
Slowlyness of processing
Jun 28th, 2009, 1:47pm
 
Hi,
on ubuntu studio 9.04 and PROCESSING 1.0 (REV 0162), this simple ex runs very slow on size(500,500); while it runs fine on size(100,100);
Is that normal ?

here is the programme (very simple):
Spot sp;

void setup() {
 size(500,500);
 smooth();
 noStroke();
 sp=new Spot(33,50,30,1.5);
}

void draw() {
 fill(0,15);
 rect(0,0,width,height);
 fill(255);
 sp.move();
 sp.display();
}

class Spot {
 float x,y;
 float diameter;
 float speed;
 int direction=1;

 Spot(float xpos, float ypos, float dia, float sp) {
   x=xpos;
   y=ypos;
   diameter=dia;
   speed=sp;
 }

 void move() {
   y+=(speed * direction);
   if ((y>(height-diameter/2)) || (y<diameter/2)) {
     direction*=-1;
   }
 }
 void display(){
   ellipse(x,y, diameter,diameter);
 }
}

Thanks for letting me know.
Alex
Re: Slowlyness of processing
Reply #1 - Jun 28th, 2009, 3:32pm
 
It's moving the same speed. It just looks slower because it's got more ground to cover. Kind of how a plane flying 30,000 feet above your head looks like it's moving way slower than it is.

Anyway, if you want it to go faster, input a faster speed when you create the object.  Wink

Try calling this in setup():
Code:

sp=new Spot(33,50,30,5);


Re: Slowlyness of processing
Reply #2 - Jun 28th, 2009, 3:57pm
 
To put NoChin's reply another way:

Code:
Spot sp;
Spot sp2;

void setup() {
size(500,500);
background(0);
smooth();
noStroke();
sp=new Spot(33,50,30,1.5);
sp2=new Spot(73,50,30,1.5);
}

void draw() {
fill(0,15);
rect(0,0,width,height);
stroke(150);
rect(0,0,100,100);
noStroke();
fill(255);
sp.move();
sp.display();
sp2.move();
if(sp2.y>100-15) {
  sp2.direction *= -1;  
}
sp2.display();
}

class Spot {
float x,y;
float diameter;
float speed;
int direction=1;

Spot(float xpos, float ypos, float dia, float sp) {
  x=xpos;
  y=ypos;
  diameter=dia;
  speed=sp;
}

void move() {
  y+=(speed * direction);
  if ((y>(height-diameter/2)) || (y<diameter/2)) {
    direction*=-1;
  }
}
void display(){
  ellipse(x,y, diameter,diameter);
}
}
Re: Slowlyness of processing
Reply #3 - Jun 29th, 2009, 12:28pm
 
OK so the reply to my answer is:
It works fine on my computer !
I guess something has to be wrong with java, it is really really slow you can see the ball moving a frame per second (or close).
How can I test  the performance of processing ?
Are you guys on the same system than mine and if yes can you gave me the version of your dependencies.
I am not even sure of what are they actually, java something...
Alex
Re: Slowlyness of processing
Reply #4 - Jun 29th, 2009, 2:44pm
 
I'm running Processing 1.03 (Note that the latest version is 1.05 - rev 0167) on Windows XP on a 2Ghz core Duo with 2Gb RAM.  It runs perfectly well on my machine.  Updating Processing might be a good place to start.

I did wonder at first whether you meant it was actually slow, rather than perceptually so...  One thing I did notice was that CPU usage increased substantially at 500 by 500 compared to 100 by 100 - from around 15% to around 55%; though that's not entirely unexpected since it's got more pixels to render.

Note that the default frameRate is 60.  If I set it to 30 and double the speed parameter of the ball it does look slightly smoother and the cpu usage drops to around 35%.

Now here's something interesting.  I'm just running one of my sketches (at 30 fps) that involves 10 balls bouncing around at random, being influenced by gravity and friction and with collision detection between them all and it's averaging around 40%...  From which I would surmise that it's something to do with having to render a larger display window that causes the greater CPU load.

One thing I've found in the past is that invoking the OPENGL renderer can improve 2D performance (import opengl library from the Sketch menu and then: size(500,500,OPENGL) - assuming you have a graphics card that supports it...)

Also for testing you can println(frameRate);
Re: Slowlyness of processing
Reply #5 - Jun 29th, 2009, 3:27pm
 
Hi,

I'm on Ubuntu 8.04 and your sketch runs fine. If you are seeing 1-frame-per-second rates, then it could be that your drivers don't support your graphic card correctly. Please do

> lspci | grep -i vga
This gives you which card you have,

and then look if your card is listed in this post:
https://bugs.launchpad.net/ubuntu/+source/sun-java6/+bug/250931

if it is, then you could set another renderer like blindfish says.
Actually there are several other possible workarounds on that page.

alvaro
Re: Slowlyness of processing
Reply #6 - Jun 30th, 2009, 11:31am
 
I've gotten wildly different performance between the different processing renderers on different machines.

Try:

size(500,500,P2D);

or

size(500,500,P3D);

or put this at the top:

import processing.opengl.*;

and use this in your setup function:
size(500,500,OPENGL);


It is very strange that you'd be seeing only 1 frame per second, I agree with alvaro that it sounds like a graphics card issue but what are the specs of the machine you're running it on?

You're using the JAVA2D renderer (default) which is slower for sure, but it could be that you don't have enough video or system memory on the machine you're using.

For a double buffered app with a 500 by 500 pixel view (which probably gets upscaled to the next power of two which would be 512 by 512) results in:

2 buffers * 262144 pixels * 4 bytes per pixel (32 bit color) = 2MB free ram depending on what type of memory the Java2D renderer requires.

You might not have that if you're running on a netbook with integrated graphics and you're running the full Ubuntu - but that's just a guess I could be way off.

Anyways, I just wanted to add a bit more info to the pile! I hope you get it working!

Jack





Page Index Toggle Pages: 1