FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Discussion
   General Processing Discussion
(Moderators: fry, REAS)
   processing performance question
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: processing performance question  (Read 2637 times)
minh


processing performance question
« on: Jan 1st, 2005, 7:09pm »

i made a execise where there are 500 objects moving around on screen in Processing then I recreated the same excercise with JAVA. there seems to be no drastic performance issues. they seem to run about the same speed.... shouldn't there be a difference?
 
i'd expected the JAVA excercise to run faster.
 
fjen

WWW
Re: processing performance question
« Reply #1 on: Jan 4th, 2005, 6:02pm »

since processing is java underneath it's like comparing two flash projects ...
 
/F
 
fry


WWW
Re: processing performance question
« Reply #2 on: Jan 4th, 2005, 9:03pm »

in terms of execution speed, things will be identical. but graphics rendering speed will be different, sometimes faster in processing but more often slower, since we're building up from pixels in processing whereas some types of straight java drawing can be done more quickly.
 
toxi

WWW
Re: processing performance question
« Reply #3 on: Jan 8th, 2005, 1:23pm »

even though processing is quite slow for bigger window sizes one can drastically improve performance by limiting the pixels being redrawn to a specified area only. the code below just demonstrates the approach, but you'll have to keep track of the "dirty" area yourself.
 
this example only redraws the area around the mouse when the mouse has been moved. note: only because the screen doesn't update when the mouse is static doesn't mean the loop() method is executed less often. you can still saveFrame() every frame to see its progress...
 
Code:
// clipping rect demo
// author: info@toxi.co.uk
 
// flag if screen actually needs a redraw (initially true)
boolean isDirty;
// area of screen which will be redrawn
Rectangle dirtyRect;
 
void setup() {
  size(400,400);
  noStroke();
  // allow redraw initially
  isDirty=true;
  // set paint area to full window size for first iteration
  dirtyRect=new Rectangle(0,0,width,height);
}
 
void loop() {
  // draw random rectangles every frame
  fill(random(255));
  rect(random(width),random(height),random(width),random(height));
}
 
// only allow redraw for the area around mouse
// AND only if mouse has moved
 
void mouseMoved() {
  setDirty(mouseX-50,mouseY-50,mouseX+50,mouseY+50);
}
 
// call this whenever you have drawn something
// only required once per frame
 
void setDirty() {
  isDirty=true;
}
 
// alternate version to specify area to be redrawn
void setDirty(int x1, int y1, int x2, int y2) {
  isDirty=true;
  dirtyRect.setBounds(x1,y1,x2-x1,y2-y1);
}
 
// overwrites BApplet.update() and only repaints when really necessary
public void update() {
  if (isDirty) {
    isDirty = false;
    Graphics gfx = this.getGraphics();
    if (gfx != null) {
 gfx.setClip(dirtyRect);
 paint(gfx);
    }
  }
}
 

http://toxi.co.uk/
Pages: 1 

« Previous topic | Next topic »