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 › Processing Performance Test
Page Index Toggle Pages: 1
Processing Performance Test (Read 566 times)
Processing Performance Test
May 9th, 2008, 2:59pm
 
Hi guys!

 I noticed some of my processing programs were slowing down a lot and I didn't know why. First I tried to optimize all I could and then I just tried to test the Processing's core performance.

 For that I made a fps counter (as simple as I possibly could, not to influence the performance) that only draws the current frame rate calculated from the time elapsed between the current frame and the last one in a plain black background.

 I noticed that the program could only mantain a 30fps rate at a window size below 525*230 pixels. More than that and the frame rate drops DRASTICALLY!!!! at 1024*768 I get only 4fps!!!!!!!!! with almost nothing being done in the program!!!!

 Then I tried to include the frame counter in a heavy(er) program that I made that deals with lot of classes, video, sound etc... and the behavior didn't change!!! I could still get a 30fps at 525*230 and at 1024*768 i got 5fps ?!?!?!?!?!?!  

 I repeated the test in a p4 2,66GHz with 512Mb RAM and in a AMD Turion 64 2GHz 2Gb RAM and the results were the same!?!?!?!?!?!?!?!?!?!?!?

 Next is the code for the fps counter, please try it with diferent screen sizes and share your conclusions. Do you know what this problem is about??? It's really really strange!!


(I am using eclipse and I am only including in the project the core.jar lib)

PS - I am drawing the frame rate on the screen with the Arial.vlw font so you must create it with the processing IDE and put it inside the "bin" folder of your project

Code:

import processing.core.*;

public class FPSCounter extends PApplet{

private static final long serialVersionUID = 1L;
long lastFrame;
float appFps;
PFont arial;
boolean freeze;
float freezeVal;


public void setup()
{
//size(525, 230);
size(1024, 768);
lastFrame = millis();
arial = loadFont("Arial.vlw");
frameRate(30);
freeze = false;
freezeVal = 0;
}

public void draw()
{
background(0);
int timeElapsed = (int)(millis() - lastFrame);
if(timeElapsed != 0)
appFps =(float) 1000 / timeElapsed;
lastFrame = millis();

if(!freeze)
{
textFont(arial);
fill(255);
text(appFps, 0, 40);
}
else
{
textFont(arial);
fill(255);
text(freezeVal, 0, 40);
}
}

public void keyPressed()
{
if (keyCode == ' ')
{
freeze = !freeze;
freezeVal = appFps;

}
}
}



Thanks in advance!!!

 Bye!
Re: Processing Performance Test
Reply #1 - May 9th, 2008, 6:50pm
 
Erm, writing text to the screen isn't a quick operation.. it's much quicker using println() to print to the console.. and there's a build in frameRate variable that contains the current framerate.

Having said that, the default renderer is slow relative to frame size, as it has to copy the window to screen each frame, and this isn't that quick, and so the bigger the screen the slower it goes.

If you want it to run quicker, use P3D or even OpenGL.
Re: Processing Performance Test
Reply #2 - May 13th, 2008, 12:47pm
 
Thanks!!

 Just using P3D did the trick, and it worked like a charm!!

 Now I get the same frame rate at all sizes and the images and videos look better!
Page Index Toggle Pages: 1