Low fps problem

My sketch has 10 images, with stuff moving and so on, the problem is that even with the function frameRate(30) i only get 9 to 12 FPS. I had try the sketch on pretty good pc and the result is the same. The promp comand shows low consumption on CPU and Ram memory (like 20%).
I would like to know if there is some command to use more CPU power in order to increse my FPS??

Hey there!
There is threading but first we need to see your sketch to really be able to tell what the problem is.

ok, but the code has 6 classes, its realy big, here is the main code:

altimetro altimetro;
bussola bussola;
variometro variometro;
turn turn;
horizonte horizonte;
grafico grafico;

PImage fundoAltimetro,indicadorMaior,indicadorMenor;
PImage fundoBussola, ponteiroBussola;
PImage fundoVariometro,ponteiroVariometro;
PImage Turn_coordinator,Aviaozinho,bolinha;
PImage horizonteartificial, imgFundo;

//recebe data

String[] str;
float [] ano        = new float  [100000];
float [] mes        = new float  [100000];
float [] dia        = new float  [100000];
float [] hora       = new float  [100000];
float [] minuto     = new float  [100000];
float [] segundo    = new float  [100000];
float [] pressao    = new float  [100000];
float [] alt        = new float  [100000];
float [] pitch      = new float  [100000];
float [] roll       = new float  [100000];
float [] curso      = new float  [100000];
float [] velocidade = new float  [100000];
float [] alt2       = new float  [100000];  //altitude gps em Metros
double[] lat        = new double [100000];
double[] lng        = new double [100000];
int   [] sat        = new int    [100000];
int size = 350;
//int fps = 10;      //ajusta os quadros por segundo!

//tamanho da tela
//int width = 1200;
//int height = 700;

  void setup(){
  frameRate(30);      //ajustar para a velocidade de gravação do arduino
  fundoAltimetro = loadImage("imagens/fundoAltimetro.png");
  indicadorMaior = loadImage("imagens/indicadorMaior.png");
  indicadorMenor= loadImage("imagens/indicadorMenor.png");
  fundoBussola = loadImage("imagens/fundoBussola.png");
  ponteiroBussola = loadImage("imagens/ponteiroBussola.png");
  fundoVariometro = loadImage("imagens/fundoVariometro.png");
  ponteiroVariometro = loadImage("imagens/ponteiroVariometro.png");
  Turn_coordinator = loadImage("imagens/Turn_coordinator.png");
  Aviaozinho = loadImage("imagens/Aviaozinho.png");
  bolinha = loadImage("imagens/bolinha.png");
  horizonteartificial = loadImage("imagens/horizonteartificial.png");
  //inicializa as classes, posteriormente passa os valores respectivos para cada classe!
altimetro = new altimetro();
bussola = new bussola();
variometro = new variometro();
turn = new turn();
horizonte = new horizonte();
grafico = new grafico();
  str = loadStrings("data/FDR.TXT");
  String[] arry = new String[str.length];

  for (int i=0; i < arry.length; i++) {
    String[] thisLine = split(str[i] , " " );
    ano        [i]   = float (trim(thisLine[0] ));
    mes        [i]   = float (trim(thisLine[1] ));
    dia        [i]   = float (trim(thisLine[2] ));
    hora       [i]   = float (trim(thisLine[3] ));
    minuto     [i]   = float (trim(thisLine[4] ));
    segundo    [i]   = float (trim(thisLine[5] ));
    pressao    [i]   = float (trim(thisLine[6] ));
    alt        [i]   = float (trim(thisLine[7] ));
    pitch      [i]   = float (trim(thisLine[8] ));
    roll       [i]   = float (trim(thisLine[9] ));
    curso      [i]   = float (trim(thisLine[10]));
    velocidade [i]   = float (trim(thisLine[11]));
    alt2       [i]   = float (trim(thisLine[12]));
    lat        [i]   = float (trim(thisLine[13]));
    lng        [i]   = float (trim(thisLine[14]));
    sat        [i]   = int   (trim(thisLine[15]));
void draw(){
  //for(int cont = 0;cont<str.length;cont++){
  //cada instrumento possui seu proprio centro de rotação!
  //int cont = 1000;  // pega dados da linha 3000
    //função do horizonte

  //funções do altimetro
  //funções da bussola
  //funções do turn_coordinator
  turn.bolinha(bolinha, roll[p]);

Did you try and comment back those objects in draw and get to see what the performance is ?

Yes, commenting each class i got about 3fps more. But none of them i got i big improve on fps. I even reduce the images quality, from 1080p to 480p. No change on fps :no_mouth:

I dont know anything about engines but i was wonder if i try to use openGL for example, could i have a better performance? :thinking:

You could try render with P2D you put it in the size(1200,700,P2D);


Yep, the sketch went from 9 fps to 22 fps but now everything is shaking (the images) haha. I’ll try to correct but thanks for the tip :+1:

If you could give us a github repo of the full code with the problem more then happy to help !

Here is the link:

1 Like

It me again !

Your horizonte.marcacao() method is really doing it in ! To many drawing of those various shapes and text ! It strange because it not that many but it really taxing. Guess your arc’s are way to big… Besides where are they ? I don’t see any difference with it and without it commenting out the arcs fixes the issue.


Haha. Indeed is that, thanks!!!

1 Like

I recommend using images for the two arcs. That way it won’t be as taxing on the system to display the shape they are supposed to represent.

the arcs is to solve another issue on the code. They have to be big in order to mantain the color shape inside the image. its only noticable if there is a lot of moviment.

yeah, and probably it’s easier to use images too kkk

try using FX2D instead of P2D in the constructor of size. It is pretty much faster than p2d.

1 Like

Aaaaa thank you!!its useful!!!