Archive 17/01/2023.

Get current FPS

ucupumar

Do anyone know how to get/calculate current FPS on Urho? :confused:

hdunderscore

As far as I know, there’s no built in for it. Two ways come to mind:

Quick and dirty:

FrameInfo frameInfo = GetSubsystem<Renderer>()->GetFrameInfo(); text->SetText("FPS: " + String(1.0 / frameInfo.timeStep_));

Or more standard:

void FPSCounter::Update(float deltaTime) { counter += 1; timer += deltaTime; if (timer >= 0.5f) { text->SetText("FPS: " + String(counter/timer)); timer = 0.0f; counter = 0; } }

You would need to set up a ‘Text* text’ object in the above examples, and an object or event to do the update event in.

weitjong

Urho3D has a Profiler class that does just that and more. In the samples, you can press F2 to see it in action.

ucupumar

Thanks for all the answer. It works now!
I never thought it was so simple. :smiley:

@weitjong I haven’t tried profiler class, but terima kasih buat tipsnya! :smiley:

cirosantilli

I can’t find the FPS information on the current Profiler :frowning: lots of data! But the data it shows looks pretty cool.

weitjong

It is the “Cnt” at the outer block.