Remove element while being used

To find the FPS, you count the number of frames that occur in 1 second by having a frame counter and a time keeper:


int frames = 0;
long lastTime = System.nanoTime();

while(true) {
    //game loop
    
    frames++;
    if(System.nanoTime() - lastTime >= 1e9) { //1e9 = 1 * 10 ^ 9 = 1,000,000,000 nanoseconds = 1 second :)
        System.out.println(frames);
        frames = 0;
        lastTime += 1e9;
    }
}

I disagree… as you point out, if he can render a frame in 1 millisecond, his game is already running more than an order of magnitude faster than what is necessary for 60fps. There’s no need for somebody in that situation to optimize anything.

He said he got 1ms for 1 frame, which means it should have done all logic and drawing. The time may be inaccurate, but if I see that result I’m quite happy. However if 1ms is time to do an operation to an AL, could be problem.

Oh sorry, I mean 1 microsecond not millisecond :smiley: One milisecond would be a lot for the few things I’m doing (Render BG, Render Map, Render Entites between Layer, Render foreground stuff).