Doing an Android FPS counter -


i'm trying fps counter android app. means don't have source code app (i can't modify or that, have .apk).

i've researched lot , i've found one app (it's called game bench, can find on google play), possible somehow. when app starts, has list games on phone, choose 1 , game bench automatically starts , calculates fps. need similar behaviour.

now, asking is, if of has @ least idea of how calculate fps of app (without writing code in it). doing research found few vague ones, record screen , calculate fps of video, or somehow calculate fps using data collected systrace. on both these "ideas" there few info on internet.

so please, if guys have information matter/ ideas/ opinions, i'll happy hear them. thanks!

this example of how bench fps using surface view. @ run method see how fps works.

1: time before update , render screen.

2: after work done time again.

3: 1000 milliseconds second , 40 fps norm.

4: elaspedtime = starttime - endtime;

5: if elaspedtime under 25 at-least doing 40 fps.

6: if elaspedtime = 5 milliseconds doing 1000 / 5 = 200 fps

7: can sleep thread couple milliseconds if running updater , renderer on same thread. way you're not updating many times.

8: hope helps class basic game class keeps game running , 40 fps if running on galaxy s 6. want make own necessary changes tweak more.

public class mysurfaceview extends surfaceview implements runnable {     long time = 0, nextgametick = 0;     surfaceholder myholder;     thread mythread = null;     boolean myrunning = false;      public mysurfaceview(context context) {         super(context);         myholder = getholder();     }      @override     public void run() {         while (myrunning) {             nextgametick = system.currenttimemillis();             if (!myholder.getsurface().isvalid())                 continue;             update();             render();             time = nextgametick - system.currenttimemillis();             time = (time <= 0) ? 1 : time;             if (time <= 25)                 sleepthread(25 - time);             log.d("framerate", string.valueof(1000 / time));         }     }      public void pause() {         myrunning = false;         while (true) {             try {                 mythread.join();             } catch (interruptedexception e) {                 e.printstacktrace();             }             break;         }         mythread = null;     }      public void resume() {         myrunning = true;         mythread = new thread(this);         mythread.start();     }      public void sleepthread(long time) {         try {             thread.sleep(time);         } catch (interruptedexception e) {             e.printstacktrace();         }     }      private void render() {         // todo render screen     }      private void update() {         // todo update     } } 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -