How to change FrameRate

I am trying to set FrameRate using the framerate() function but it is not working, the actual framerate while running the code ranges between 1.8 - 4 fps , here is my setup code:

void setup (){
  System.out.println("displayHeight  : "+displayHeight);
  System.out.println("displayWidth  : "+displayWidth);
  setBG("white-frame.png");
  surface.setLocation(displayWidth/2-width/2, 0);
  surface.hideCursor() ;
  frameRate(frame_rate); // redraw 10 times in a second, refresh rate is 200 ms/frame
  //System.out.println("mapping sections List: "+Arrays.deepToString(pm.getMappingSections()));

  // Load the font
  f = createFont("font.ttf",150,true);
  textFont(f);

    file = new SoundFile(this, "Musica.mp3");
    file.play();
}

Hi

Is this your code or part of it ?

At 10 frames a second that allows a maximum of 100ms to render a frame??? If you expect the draw() method to take 200ms pef frame then the best frame rate you can get is ~5fps no matter what you put in frameRate(?).

Difficult to say more about this because we can’t the value you store in frame_rate and we can’t see how much work you expect to do in the draw() method.

this is only the setup part, I’ll post the entire code in the next comment

redraw 10 times in a second, refresh rate is 200 ms/frame
This is an old comment, the actual value of frame_rate is 100 but anyway, as I said before the execution frame rate is very low and is not affected by the value stored in frame_rate .
Regarding the other point, in the draw() function I draw images and shapes according to some values stored in a database table, the only heavy work here is the calls to the database server (in the testing process is the same machine).

void draw(){
  drawAlternater = !drawAlternater;
  setBG("white-frame.png");
  
  /// testing framerate
  textSize(100);
  textAlign(LEFT, TOP);
  text("FPS:" + frameRate, 0, 11);
  /// end of testing framerate
  
  if(introStep<maxIntroSteps) //introduction phase
  {
    intro(introStep);
    introStep++;
  }
  else if (downCounter > 0) // count down and show players' steps
  {
    finishedCountingScores = false;
    if(downCounter% frame_rate == 0)
    {
      textFont(f);
      textSize(100);
      fill(255);
      textAlign(LEFT);
      if(downCounter/frame_rate >=10)
      {
        text("00:"+downCounter/frame_rate, width/2 - textWidth("00:00")/2,displayHeight-50);
      }
      else
      {
        text("00:0"+downCounter/frame_rate, width/2 - textWidth("00:00")/2,displayHeight-50);
      }

    }

      Dictionary r = db.readPlayersTable();
      stroke(0);
      strokeWeight(GameConstants.stepStrokeWeight);
      rb.redraw((int)r.get("RED"));
      bb.redraw((int)r.get("BLUE"));
      gb.redraw((int)r.get("GREEN"));
      yb.redraw((int)r.get("YELLOW"));
      setFG("white-mask.png");

      // decrement counter
      if(downCounter > 0)downCounter--;
    }
    else if(!finishedCountingScores)
    {
      countScores(drawAlternater);

    }
    else
    {
      // show winner
      showWinner();
    }
  }