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!