Physics Update Pace

Hello! Since I’ve having some physics lag in a game of mine, I made a program that I “think” can calculate the rate at which the physics engine updates and I thought I’d share it.

-- Physics Speed Test
FPS = 60
local elapsedTime = 0
local memory = 0

function setup()
    phyFps = PhysicsFps()
end

-- This function gets called once every frame
function draw()

    background(40, 40, 50)
    
    
    phyFps:UpdateFps()
    phyFps:draw()
end

PhysicsFps = class()
-- Needs main to calc FPS
function PhysicsFps:init(x)
    self.previousPos = vec2(0,0)
    self.r = 50
    self.circle = physics.body(CIRCLE,self.r)
    self.circle.position = vec2(WIDTH/2,HEIGHT/2)

    self.circle.gravityScale = 0
    self.circle.linearVelocity = vec2(1,0)
    self.circle.interpopulate = true
end

function PhysicsFps:UpdateFps()
    local FPS = FPS * 0.9 + 0.1 / DeltaTime
    self.deltaX = self.circle.x - self.previousPos.x
    print("deltaX",self.deltaX)
    self.physicsFps = (self.deltaX/(1/FPS)) * FPS

    self.previousPos = vec2(self.circle.x,self.circle.y)
    pushStyle()
    fontSize(50)
    fill(255, 255, 255, 255)
    text(string.format("%.0fPhyscicsUPS",self.physicsFps),WIDTH/2,HEIGHT/2)
    popStyle()
end

function PhysicsFps:GetFps()
    return self.physicsFps
end

function PhysicsFps:draw()
    pushStyle()
    fontSize(50)
    fill(255, 255, 255, 255)
    text(string.format("%.0fPhyscicsFPS",self.physicsFps),WIDTH/2,HEIGHT/2)
    popStyle()
end