1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | LARGE_INTEGER perfCountFrequencyResult; QueryPerformanceCounter(&perfCountFrequencyResult); int64_t perfCountFrequency = perfCountFrequencyResult.QuadPart; // Open window (1280x720) LARGE_INTEGER lastCounter; QueryPerformanceCounter(&lastCounter); int64_t lastCycleCount = __rdtsc(); while (app.isRunning) { // Draw around 5 bitmaps (256x256) and a couple of triangles to the screen using OpenGL int64_t endCycleCount = __rdtsc(); LARGE_INTEGER endCounter; QueryPerformanceCounter(&endCounter); int64_t cycleElapsed = endCycleCount - lastCycleCount; int64_t counterElapsed = endCounter.QuadPart - lastCounter.QuadPart; float msPerframe = ((1000.0 * (float)counterElapsed) / (float)perfCountFrequency); float fps = (float)perfCountFrequency / (float)counterElapsed; float mcpf = ((float)cycleElapsed / 1000000.0); printf("%fms/f / %fFPS / %fMC/F\n", msPerframe, fps, mcpf); // A sample: (0.000018ms/f / 56302504.000000FPS / 22.228949MC/F) lastCounter = endCounter; lastCycleCount = endCycleCount; } |
Is there anything wrong with my code? Or it's just that I'm doing too little work and my pc is too fast?