In the demo application, reset the FPS counter every hundred frames.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 8 Jan 2014 20:28:08 +0000 (21:28 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 8 Jan 2014 20:28:08 +0000 (21:28 +0100)
Gives much, much better FPS counts for benchmarking.

demo.cpp

index 0083f68..cd9fe9f 100644 (file)
--- a/demo.cpp
+++ b/demo.cpp
@@ -303,6 +303,15 @@ int main(int argc, char **argv)
                printf("%d frames in %.3f seconds = %.1f fps (%.1f ms/frame)\n",
                        frame, elapsed, frame / elapsed,
                        1e3 * elapsed / frame);
                printf("%d frames in %.3f seconds = %.1f fps (%.1f ms/frame)\n",
                        frame, elapsed, frame / elapsed,
                        1e3 * elapsed / frame);
+
+               // Reset every 100 frames, so that local variations in frame times
+               // (especially for the first few frames, when the shaders are
+               // compiled etc.) don't make it hard to measure for the entire
+               // remaining duration of the program.
+               if (frame == 100) {
+                       frame = 0;
+                       start = now;
+               }
 #endif
        }
        return 0; 
 #endif
        }
        return 0;