timing
This commit is contained in:
parent
4baeca1603
commit
b41ec7960c
3 changed files with 32 additions and 1 deletions
|
|
@ -71,7 +71,30 @@ void Window::LogTiming() {
|
|||
for (const std::tuple<const RenderingElement*, std::uint_fast32_t, std::uint_fast32_t, std::chrono::nanoseconds>& entry : renderTimings) {
|
||||
std::cout << std::format("\t{} {}x{} {}", reinterpret_cast<const void*>(std::get<0>(entry)), std::get<1>(entry), std::get<2>(entry), duration_cast<std::chrono::microseconds>(std::get<3>(entry))) << std::endl;
|
||||
}
|
||||
std::cout << std::format("Total: {}", duration_cast<std::chrono::milliseconds>(totalUpdate+totalRender)) << std::endl;
|
||||
std::cout << std::format("Vblank: {}", duration_cast<std::chrono::milliseconds>(vblank)) << std::endl;
|
||||
std::cout << std::format("Total: {}", duration_cast<std::chrono::milliseconds>(totalUpdate+totalRender+vblank)) << std::endl;
|
||||
|
||||
// Add 100-frame average and min-max timing info
|
||||
if (!frameTimes.empty()) {
|
||||
// Calculate average
|
||||
std::chrono::nanoseconds sum(0);
|
||||
for (const auto& frameTime : frameTimes) {
|
||||
sum += frameTime;
|
||||
}
|
||||
auto average = sum / frameTimes.size();
|
||||
|
||||
// Find min and max
|
||||
auto min = frameTimes.front();
|
||||
auto max = frameTimes.front();
|
||||
for (const auto& frameTime : frameTimes) {
|
||||
if (frameTime < min) min = frameTime;
|
||||
if (frameTime > max) max = frameTime;
|
||||
}
|
||||
|
||||
std::cout << std::format("Last 100 Frame Times - Avg: {}, Min: {}, Max: {}",
|
||||
duration_cast<std::chrono::milliseconds>(average),
|
||||
duration_cast<std::chrono::milliseconds>(min),
|
||||
duration_cast<std::chrono::milliseconds>(max)) << std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue