# Why does it take some time for my program to get up to speed?

**URL:** <https://discourse.processing.org/t/why-does-it-take-some-time-for-my-program-to-get-up-to-speed/43309>\
**Category:** Processing\
**Created:** [November 25, 2023, 7:44pm UTC](https://discourse.processing.org/t/why-does-it-take-some-time-for-my-program-to-get-up-to-speed/43309 "2023-11-25T19:44:24Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [November 25, 2023, 8:06pm UTC](https://discourse.processing.org/t/why-does-it-take-some-time-for-my-program-to-get-up-to-speed/43309/2 "2023-11-25T20:06:54Z")

</div>

Hello @adrinalino,

Scrutinize this code and give it a try:

```auto
int num = 1_000_000;

int t2;

void setup() 
  {
  size(1000, 800);
  frameRate(1000); // maximum possible it won't achieve this
  t2 = millis();
  }

void draw() 
  {
  background(0);
  float sum = 0;
  for (int i = 0; i < num; i++) 
    {
    float alfa0 = map(i, 0, num, 0, TAU);
    float alfa1 = map(i+1, 0, num, 0, TAU);
    sum += sin(alfa0) - sin(alfa1);
    sum -= cos(alfa0) + cos(alfa1);
    }
  
  //println(sum);
  noStroke();
  fill(0);
  rect(0, 0, 85, 25);
  fill(255);
  textSize(40);
  text("FPS " + 1000.0*frameCount / millis(), 2, 40);
  text("FrameRate: " + frameRate, 2, 80);
  text("FrameRate: " + 1000.0/(millis()-t2), 2, 120);
  t2 = millis();
  }

```

I know that _frameRate_ gives a rolling average so I used time between frames for real time updates.

Related:

> [@FrameRate hiccups](https://discourse.processing.org/t/framerate-hiccups/11947):
>
> I have experienced hiccups in my animations at the start of my animations and trying to understand why this happens. Is it Processing, Java or other? I have reduced it down to a simple example that displays frameRates below a threshold of 54 fps: float threshold = 54; // fps int y = 100; // spacing for text void setup() { size(700, 750, P3D); background(0); textSize(24); } void draw() { // background(0); float temp = frameRate; if (temp \< threshold) { pr…

Reference:

> **[frameRate / Reference](https://processing.org/reference/frameRate.html)**
>
> The system variable frameRate contains the approximate frame rate of the software as it executes. The initial value is 10 fps and is updated with each frame. The value is averaged (integrated) …

`:)`

---

_[View the full topic](https://discourse.processing.org/t/why-does-it-take-some-time-for-my-program-to-get-up-to-speed/43309)._
