Last active
January 26, 2023 04:12
-
-
Save Mischa-Alff/bf1fbd248b116765fc57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::chrono::high_resolution_clock::time_point start, end, timetoprint; | |
timetoprint = start = end = std::chrono::high_resolution_clock::now(); | |
long long frame_count=0; | |
long double frametime_total=0.f; | |
while(!glfwWindowShouldClose(win)) { | |
end = std::chrono::high_resolution_clock::now(); | |
long int frametime_us = (std::chrono::duration_cast<std::chrono::microseconds>(end-start).count()); | |
float frametime_s = ft/1e6f; | |
frametime_total += frametime_us; | |
++frame_count; | |
if(std::chrono::duration_cast<std::chrono::seconds>(end-timetoprint).count() >= 1) { | |
timetoprint = std::chrono::high_resolution_clock::now(); | |
float frametime_avg = frametime_total/count; | |
float fps_avg = 1e6f/frametime_avg; | |
std::wstring frametimestr = L"FPS avg: "+std::to_wstring(fps_avg) + L"\t" L"Frametime avg: "+std::to_wstring(frametime_avg)+L"µs\n"; | |
wlog.log(frametimestr); | |
count=0; | |
frametime_total=0; | |
} | |
start=end; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment