FPSGraph

Monkey Forums/Monkey Code/FPSGraph

Raph(Posted 2013) [#1]
I have been looking at frame rate issues on Android, and I needed a better performance monitor than just seeing FPS. I threw this together in the last hour, and I thought it might be useful to others.

What it does:

By default, it draws a scrolling graph in the upper corner showing the last 300 frames and their times. It actually draws it two ways -- raw data, and a smoothed line (the smoothing is much easiler to read, though it obviously isn't accurate). If any frames are under half the UpdateRate (e.g. target framerate) it'll flag those visibly and show you what FPS they were.

Some options:

- You can set X and Y to move it around
- You can set it to show nothing, FPS only, or the full graph
- You can set it to different length graphs with "graphMax"
- You can draw it different sizes with "graphSize"

Previous update:
- there's a method for setting visibility
- the black background tis oggleable; by default, it's off.
- the smoothed line has color coding (fades between red and green)
- it's now Strict

Latest update:
- Now does all calculations in OnRender, for greater accuracy
- No longer needs to be instantiated -- why would you use more than one? Instead, it comes with a global called fpsGraph, just draw it.



Usage:




muddy_shoes(Posted 2013) [#2]
Neat, thanks for sharing.

By the way, if you have ongoing issues with Android performance I'd be glad to help out. I've spent a fair amount of time optimising for Android with Monkey with the Box2D port and other bits and bobs.


Raph(Posted 2013) [#3]
Thanks! Looks like it's probably just an AI routine that is slow. But if it turns out to be more, I may be back asking for help. :)


Raph(Posted 2014) [#4]
Taiphoz did a somewhat nicer version of this, but if anyone is still using mine, here's a minor update:

- new method for setting visibility
- made the black background toggleable; by default, it's off.
- made the bar graph part (the gray) have alpha to it
- made the smoothed line have color coding (fades between red and green)
- it's now Strict

Code updated in the original post.


Raph(Posted 2014) [#5]
Just updated this after reading http://www.monkey-x.com/Community/posts.php?topic=6216

Latest update:
- Now does all calculations in OnRender, for greater accuracy
- No longer needs to be instantiated -- why would you use more than one? Instead, it comes with a global called fpsGraph, just draw it.