Calculate FPS in an Android app which does rendering via SKIA

閲覧: 100 回
最初の未読メッセージにスキップ

pearleye

未読、
2023/04/27 8:35:052023/04/27
To: skia-discuss
Hi

I'm using the below android application which does some rendering via JNI calls to SKIA library.


And I would like to measure/calculate the FPS which I haven't figured it out yet. Can someone let me know how to do it?

Thank you.

Jim Van Verth

未読、
2023/04/27 10:37:362023/04/27
To: skia-d...@googlegroups.com
You can look at StatsLayer in tools/viewer for some ideas. But basically you accumulate the frame time over a certain number of frames, and then compute <# frames>/<accumulated time>.  Usually there's a circular buffer of times that you cycle through so that old times get purged, or you can try to compute a running average. And milliseconds/frame is usually a better measure.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/118d0aad-d4c9-4f12-a21c-07a457203314n%40googlegroups.com.


--

Jim Van Verth |
 Software Engineer | Google.com

craste...@gmail.com

未読、
2023/04/30 10:38:022023/04/30
To: skia-discuss
Is there any sort of "system time" API in android which will tell you how many milliseconds have passed since 1970-something?
The standard FPS calculation is to gather those numbers for each rendering pass and do a bit of softening of the peaks and valleys by averaging a certain number of them against each other.
It isn't really Skia's job to provide such an API. The platform should already offer tools to do it yourself.

pearleye

未読、
2023/04/30 19:30:222023/04/30
To: skia-discuss
@jvan, Thanks for your input. I had a look at the file which you mentioned and wanted to know if I can consider a frame is created
 on each call of onPaint() which does the drawing in canvas?

Jim Van Verth

未読、
2023/05/01 9:57:422023/05/01
To: skia-d...@googlegroups.com
Skia provides SkTime which is a platform-independent way to get at the system time.

As far as a "frame", that's whatever you want to consider it to be. The usual approach is to measure the time between swaps of the backbuffer (e.g., that's swapBuffers() in sk_app::WindowContext).  To do that you could start a timer when you start drawing content, and then stop and record it when you start drawing content for the next frame (and start a new one, etc.). But you could measure the time from when you start drawing the content to when you call SkCanvas::flush(). That would leave out any time taken up by the swapchain, however, so may not be what you're looking for.

But other than the SkTime interface this is outside of Skia really -- StackOverflow has some examples of how to do this in general.

全員に返信
投稿者に返信
転送
新着メール 0 件