Initializing multiple timers within the draw loop ()

2nd example

a variable timer2 is taken in the second part and wen you say millis()-timer2 you get a 2nd time

DEMO


int xPos = 0;
int timer1 ;
int timer2 ;

float a1;

boolean firstTime=true; 

void setup() { 
  size(400, 400);
  noStroke();
} 

void draw() { 
  background(220);

  print("1st timer ");
  timer1 = (millis());
  println(timer1);
  fill(255, 200, 40);
  rect(xPos, 180, 40, 40);

  for (int i2=0; i2 <22; i2++) {
    for (int i=0; i <91111; i++) {
      a1 = sin(radians (i)) * cos(456);
    }// for
  }// for 
  println(a1); 

  xPos = xPos + 1;
  if (firstTime) { 
    timer2 = (millis());
    firstTime=false;

    print("the new timer starts at ");
    println(timer2);
  }

  println(millis()-timer2);
  fill(0, 255, 0);
  rect(100, 100, 200, 200);
  // }

  println("");

  if (frameCount==10) 
    noLoop();
}
//