Author Topic: Framerate counter  (Read 289 times)

zpaolo11x

  • Sr. Member
  • ****
  • Posts: 201
    • View Profile
Framerate counter
« on: August 25, 2018, 02:13:23 AM »
There's probably a better way to see if a theme is smooth or not, but this small code allowed me to track the performance of my theme while adding lots and lots of shaders...

Code: [Select]

local monitor = fe.add_text ("",0,0,fe.layout.width,100)
monitor.align = Align.Centre
monitor.set_bg_rgb (255,0,0)
monitor.charsize = 50

local monitor2 = fe.add_text ("",0,0,1,1)
local monitor_tick0 = 0
local monitor_x0 = 0

fe.add_ticks_callback(this,"monitortick")

function monitortick(tick_time){
monitor2.x ++
if (monitor2.x - monitor_x0 == 10) {
monitor.msg = 10000/(tick_time - monitor_tick0)
monitor_tick0 = tick_time
monitor_x0 = monitor2.x
}

if (monitor2.x >= flw) {
monitor2.x = 0
monitor_x0 = 0
monitor_tick0=0
}
}


You can add it at the end of your layout, it will create a red banner on the top with a number reporting the current frame rate. It works like this: every tick_callback it moves a text object by one pixel, once the object has moved 10 pixels it calculates the time taken. Ideally if you are on a 60Hz screen you should get a pixel movement every 1/60 of a second and on this basis the framerate is calculated and displayed.

Favdeacon

  • Full Member
  • ***
  • Posts: 88
    • View Profile
Re: Framerate counter
« Reply #1 on: August 25, 2018, 02:56:05 AM »
Nice idea, thank you!

keilmillerjr

  • Hero Member
  • *****
  • Posts: 635
    • View Profile
Re: Framerate counter
« Reply #2 on: August 25, 2018, 06:40:14 AM »
Cool! Thank you!

Perhaps we roll this into a plugin? Willing to add it to my debug plugin?
« Last Edit: August 25, 2018, 07:20:54 AM by keilmillerjr »

zpaolo11x

  • Sr. Member
  • ****
  • Posts: 201
    • View Profile
Re: Framerate counter
« Reply #3 on: August 26, 2018, 09:44:29 AM »
Perhaps we roll this into a plugin? Willing to add it to my debug plugin?

It's a nice idea but I don't know how to program plugins :( If it's not too difficult I can do it for sure

keilmillerjr

  • Hero Member
  • *****
  • Posts: 635
    • View Profile
Re: Framerate counter
« Reply #4 on: September 02, 2018, 05:07:06 PM »
I talked to zpaolo11x, and with his permission, added his idea into the Debug plugin! If you guys have any other ideas that would help you through the development process, be sure to let me know and I can add them as well!

https://github.com/keilmillerjr/debug-plugin