# Low fps problem

**URL:** <https://discourse.processing.org/t/low-fps-problem/12313>\
**Category:** Coding Questions\
**Created:** [June 26, 2019, 4:35pm UTC](https://discourse.processing.org/t/low-fps-problem/12313 "2019-06-26T16:35:39Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![GuilhermeVolker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/guilhermevolker/32/5657_2.png) [@GuilhermeVolker](https://discourse.processing.org/u/GuilhermeVolker)\
**Post date:** [June 26, 2019, 4:35pm UTC](https://discourse.processing.org/t/low-fps-problem/12313/1 "2019-06-26T16:35:39Z")

</div>

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??

---

<div class="post-metadata">

**Author:** ![InferNova](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/infernova/32/6009_2.png) [@InferNova](https://discourse.processing.org/u/InferNova)\
**Post date:** [June 26, 2019, 5:32pm UTC](https://discourse.processing.org/t/low-fps-problem/12313/2 "2019-06-26T17:32:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GuilhermeVolker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/guilhermevolker/32/5657_2.png) [@GuilhermeVolker](https://discourse.processing.org/u/GuilhermeVolker)\
**Post date:** [June 26, 2019, 5:51pm UTC](https://discourse.processing.org/t/low-fps-problem/12313/3 "2019-06-26T17:51:59Z")

</div>

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

```auto
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(){
  //fullScreen();
  size(1200,700);
  surface.setResizable(true);
  background(0);
  smooth();
  frameRate(30); //ajustar para a velocidade de gravação do arduino
  rectMode(CENTER);
  
  //altimetro
  fundoAltimetro = loadImage("imagens/fundoAltimetro.png");
  indicadorMaior = loadImage("imagens/indicadorMaior.png");
  indicadorMenor= loadImage("imagens/indicadorMenor.png");
  //bussola
  fundoBussola = loadImage("imagens/fundoBussola.png");
  ponteiroBussola = loadImage("imagens/ponteiroBussola.png");
  //variometro
  fundoVariometro = loadImage("imagens/fundoVariometro.png");
  ponteiroVariometro = loadImage("imagens/ponteiroVariometro.png");
  //turn_coordinator
  Turn_coordinator = loadImage("imagens/Turn_coordinator.png");
  Aviaozinho = loadImage("imagens/Aviaozinho.png");
  bolinha = loadImage("imagens/bolinha.png");
  //horizonte
  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(){
  println(frameRate);
  //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
  horizonte.math(pitch[p],roll[p]);
  horizonte.fundo();
  horizonte.marcacao();
  horizonte.img(horizonteartificial);
  horizonte.translate2();
  

  //funções do altimetro
  altimetro.translado();
  altimetro.math(alt[p]);
  altimetro.fundo(fundoAltimetro);
  altimetro.indicador2(indicadorMaior);
  altimetro.indicador1(indicadorMenor);
  altimetro.translado2();
  
  //funções da bussola
  bussola.translado();
  //bussola.math(heading);
  bussola.indicador1(fundoBussola);
  bussola.indicador2(ponteiroBussola);
  bussola.translado2();
  
  //funções do turn_coordinator
  turn.translado();
  turn.fundo(Turn_coordinator);
  turn.aviao(Aviaozinho,roll[p]);
  turn.bolinha(bolinha, roll[p]);
  turn.translado2();
  
  variometro.translado();
  variometro.math(alt[p]);
  variometro.fundoVariometro(fundoVariometro);
  variometro.indicador(ponteiroVariometro);
  variometro.translado2();
 
}

```

---

<div class="post-metadata">

**Author:** ![InferNova](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/infernova/32/6009_2.png) [@InferNova](https://discourse.processing.org/u/InferNova)\
**Post date:** [June 26, 2019, 6:52pm UTC](https://discourse.processing.org/t/low-fps-problem/12313/5 "2019-06-26T18:52:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GuilhermeVolker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/guilhermevolker/32/5657_2.png) [@GuilhermeVolker](https://discourse.processing.org/u/GuilhermeVolker)\
**Post date:** [June 26, 2019, 7:06pm UTC](https://discourse.processing.org/t/low-fps-problem/12313/6 "2019-06-26T19:06:51Z")

</div>

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 😶

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

---

<div class="post-metadata">

**Author:** ![InferNova](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/infernova/32/6009_2.png) [@InferNova](https://discourse.processing.org/u/InferNova)\
**Post date:** [June 26, 2019, 8:17pm UTC](https://discourse.processing.org/t/low-fps-problem/12313/7 "2019-06-26T20:17:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GuilhermeVolker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/guilhermevolker/32/5657_2.png) [@GuilhermeVolker](https://discourse.processing.org/u/GuilhermeVolker)\
**Post date:** [June 26, 2019, 8:40pm UTC](https://discourse.processing.org/t/low-fps-problem/12313/8 "2019-06-26T20:40:22Z")

</div>

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 👍

---

<div class="post-metadata">

**Author:** ![InferNova](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/infernova/32/6009_2.png) [@InferNova](https://discourse.processing.org/u/InferNova)\
**Post date:** [June 26, 2019, 10:40pm UTC](https://discourse.processing.org/t/low-fps-problem/12313/9 "2019-06-26T22:40:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GuilhermeVolker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/guilhermevolker/32/5657_2.png) [@GuilhermeVolker](https://discourse.processing.org/u/GuilhermeVolker)\
**Post date:** [June 26, 2019, 11:28pm UTC](https://discourse.processing.org/t/low-fps-problem/12313/10 "2019-06-26T23:28:54Z")

</div>

Here is the link:

> **[GuilhermeVolker/Flight-animation](https://github.com/GuilhermeVolker/Flight-animation)**
>
> Contribute to GuilhermeVolker/Flight-animation development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![InferNova](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/infernova/32/6009_2.png) [@InferNova](https://discourse.processing.org/u/InferNova)\
**Post date:** [June 26, 2019, 11:54pm UTC](https://discourse.processing.org/t/low-fps-problem/12313/11 "2019-06-26T23:54:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GuilhermeVolker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/guilhermevolker/32/5657_2.png) [@GuilhermeVolker](https://discourse.processing.org/u/GuilhermeVolker)\
**Post date:** [June 26, 2019, 11:57pm UTC](https://discourse.processing.org/t/low-fps-problem/12313/12 "2019-06-26T23:57:59Z")

</div>

Haha. Indeed is that, thanks!!!

---

<div class="post-metadata">

**Author:** ![InferNova](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/infernova/32/6009_2.png) [@InferNova](https://discourse.processing.org/u/InferNova)\
**Post date:** [June 27, 2019, 12:00am UTC](https://discourse.processing.org/t/low-fps-problem/12313/13 "2019-06-27T00:00:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GuilhermeVolker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/guilhermevolker/32/5657_2.png) [@GuilhermeVolker](https://discourse.processing.org/u/GuilhermeVolker)\
**Post date:** [June 27, 2019, 12:01am UTC](https://discourse.processing.org/t/low-fps-problem/12313/14 "2019-06-27T00:01:59Z")

</div>

> [@InferNova](#):
>
> Guess your arc’s are way to big… Besides where are they ?

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.

---

<div class="post-metadata">

**Author:** ![GuilhermeVolker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/guilhermevolker/32/5657_2.png) [@GuilhermeVolker](https://discourse.processing.org/u/GuilhermeVolker)\
**Post date:** [June 27, 2019, 12:03am UTC](https://discourse.processing.org/t/low-fps-problem/12313/15 "2019-06-27T00:03:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Toni](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/toni/32/5386_2.png) [@Toni](https://discourse.processing.org/u/Toni)\
**Post date:** [July 2, 2019, 8:18am UTC](https://discourse.processing.org/t/low-fps-problem/12313/16 "2019-07-02T08:18:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AbleYudada](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ableyudada/32/14190_2.png) [@AbleYudada](https://discourse.processing.org/u/AbleYudada)\
**Post date:** [November 16, 2020, 8:56am UTC](https://discourse.processing.org/t/low-fps-problem/12313/17 "2020-11-16T08:56:50Z")

</div>

Aaaaa thank you！！its useful!!!
