# How to make a simple FPS counter

Here is the link to a simple FPS counter

(The project explains everything)

10 Likes

Cool tutorial, thanks for sharing!

7 Likes

Great tutorial, and it works great.

Hereâ€™s a more accurate version:

You might be wondering why I used 966.666667 milliseconds instead of 1 second.

Thatâ€™s because itâ€™s to compensate for the 2 extra frames it takes for each loop.

1 - 2/60 = 0.9666666666666â€¦ (966.66666666â€¦ms)

FPS (Frames Per Second) will depend on your device and the operations being done in the project. Lag occurs when operations take more than 1 frame (16.66666667 ms) to complete.

This can happen due to massive cloning, attempting to do lots of operations on multiple clones at once, etc.

6 Likes

I wonder if another option is to subtract 2 from the frames (as 2/60 assumes that each frame takes 1/60 seconds to execute)

1 Like

It can definitely be done that way. I just did it in simplest form. (Evaluating math operators in AEâ€™s project builder wouldâ€™ve done the same thing).

1 Like

Yeah I guess the main thing with changing the Wait block is that if each frame does not take 1/60 seconds to execute (e.g. it takes longer because of lag), then the frame rate would not be accurate

1 Like

Thatâ€™s actually a good point. I just updated mine. I went for 1000 ms (1 second), and for each loop I set the frames variable to -2 instead of 0.

It stabilized at 60 FPS on my iPad Pro, and when I enabled Low Power Mode (as I knew that limits the deviceâ€™s FPS), it stabilized at 30 FPS (as expected).

The best example of lag I came across was the massive lag that occurred from bringing multiple clones to the front every frame. The frame rate started out fine, but then started dropping significantly (it was gradually getting worse). I experienced this while playing Spy Guy 96â€™s Perilous Parallelogram project a while back.

2 Likes

High FPS means the project is running smoothly

Low FPS means the project is very choppy (meaning there are pauses here and there that are too hard to miss), aka very laggy. The lower the number, the more laggy it becomes. Sometimes, when it gets too low, the program will just straight up crash.

2 Likes

I just made a little video of a method I just learned.

Itâ€™s fast, but sometimes inaccurate.

Iâ€™ll post it once CatBox is up again (502 Bad Gateway Error).

2 Likes

Hmmâ€¦ looks like Catbox is going be down for a long time. Hopefully Iâ€™ll be able to upload a video by tomorrowâ€¦

2 Likes

When the flag is clicked, the timer is reset, a variable, in this example, â€śPrevious Timer,â€ť is set to 0 and and a forever loop starts.

In this loop, another variable, in this example, â€śFPS,â€ť is always set to 1 divided by the current value of the timer subtracted by the value of the â€śPrevious Timerâ€ť variable, and the â€śPrevious Timerâ€ť variable is set to the current timer.

After this blockâ€™s script is run, the timer is reset. The value of the â€śFPSâ€ť variable is roughly the value of the current FPS Counter.

3 Likes

Cool, Welcome and thanks for sharing.

2 Likes

Cool, now Iâ€™m wondering how this worksâ€¦

2 Likes