VR Template FPSDisplay widget - displaying a moving average

I find that the real-time FPS display value tends to jump around a bit, so I smoothed it out using a moving average. Figured I’d share the blueprints in case anybody else found this useful.

It works simply by filling an array of DeltaSeconds entries to a user-defined capacity, and then for each new value, deleting the oldest entry and subtracting it from a running total and adding the new value to the array and to the running total. It then derives the moving average by dividing the running total by the number of entries in the array.

Smooths things out a bit. Rather than seeing your framerate in real-time all the time, you’ll see an average of whatever span you specify. A readout of 74 or 75 means your framerate is pretty consistently locked. Lower values will tell you roughly how often or how badly you’re dipping below 75. (A moving average of 60 doesn’t mean that you fed frames at that rate, but rather that you held 75Hz much of the time, but dropped to 35Hz for a significant number of frames.)

Hi Kmack, another option without using array that is also possible is keeping track of the sum of the deltaTime of the last N tick events then displaying the average FPS of that window and resetting the variables. Have a look at the BP I sketched, it’s a bit spaghetti but does the job.

Simply set the moving average window fps_moving_average_ticks of your choice. Setting the window to 1 tick results in an equivalent behaviour to simply returning fps = 1 / deltaTime.