We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
static int first = 0; static int cFrames = 0; static struct timeval sNow, sLast; long int lElapsed = 0; if(first == 0) { gettimeofday(&sLast, NULL); first = 1; } else { gettimeofday(&sNow, NULL); /* Cacluate time elapsed from the last call to swap buffers */ lElapsed = (sNow.tv_sec - sLast.tv_sec) * 1000000L + (sNow.tv_usec - sLast.tv_usec); /* is time elapsed more than one second */ if(lElapsed >= 1000000) { /* Update FPS. */ float fFPS = 1000000.0f * cFrames / (float)lElapsed; printf("FPS - %.2f\n", fFPS); sLast = sNow; cFrames = 0; } cFrames++; }
private static boolean first = true;private static long prev, curr;private static int numFrames;long timeElapsed;if(first){ prev = System.nanoTime(); first = false;}else{ curr = System.nanoTime(); /* In micro seconds */ timeElapsed = (curr - prev)/1000; if(timeElapsed > 1000000){ float fFPS = 1000000.0f * numFrames / (float)timeElapsed; Log.i("AppLog", "FPS - " + fFPS); numFrames = 0; prev = curr; }else{ numFrames++; }}