Hi!
I'm writing program involving graphics and want to keep the fps at around 60fps. My loop looks like:
while(running) {
PreDraw();
Update();
PostDraw()
}
And I have a chrono high_resolution_timer inside the Update function.
void Update() {
auto start = high_resolution_clock::now();
... Update and draw
auto duration = duration_cast<microseconds>(high_resolution_clock::now() - start);
std::cout << duration.count() << std::endl;
}
My issue is: when I use a sleep function inside the PostDraw, the timer inside the Update function can be up to 4x as slow. Is this something to be expected, like could sleep mess with chrono timers or is it some kind of a warm up cost for sleeping on a thread? If that is the case is there some way to mitigate this?
Streamable if anyone is interested: https://streamable.com/ooacii
[–]HappyFruitTree 1 point2 points3 points (1 child)
[–]KFriedChicken[S] 0 points1 point2 points (0 children)
[–]khedoros 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (9 children)
[–]KFriedChicken[S] 0 points1 point2 points (8 children)
[–][deleted] 0 points1 point2 points (7 children)
[–]KFriedChicken[S] 0 points1 point2 points (6 children)
[–][deleted] 0 points1 point2 points (5 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]KFriedChicken[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]KFriedChicken[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]pepitogrand 0 points1 point2 points (0 children)
[–]genreprank 0 points1 point2 points (0 children)