mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-31 10:34:35 +08:00
ENABLE_RENDER_STATISTICS -> FPS averaged to last second
This commit is contained in:
parent
1185ec9d2a
commit
bf3786be59
@ -1681,15 +1681,13 @@ void GLCanvas3D::render()
|
|||||||
imgui.begin(std::string("Render statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
imgui.begin(std::string("Render statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||||
imgui.text("Last frame:");
|
imgui.text("Last frame:");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
imgui.text(std::to_string(m_render_stats.last_frame));
|
long long average = m_render_stats.get_average();
|
||||||
|
imgui.text(std::to_string(average));
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
imgui.text("ms");
|
imgui.text("ms");
|
||||||
imgui.text("FPS:");
|
imgui.text("FPS:");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
imgui.text(std::to_string(static_cast<int>(1000.0f / static_cast<float>(m_render_stats.last_frame))));
|
imgui.text(std::to_string((average == 0) ? 0 : static_cast<int>(1000.0f / static_cast<float>(average))));
|
||||||
// imgui.text("Imgui FPS: ");
|
|
||||||
// ImGui::SameLine();
|
|
||||||
// imgui.text(std::to_string(static_cast<int>(ImGui::GetIO().Framerate)));
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
imgui.text("Compressed textures:");
|
imgui.text("Compressed textures:");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -1707,8 +1705,6 @@ void GLCanvas3D::render()
|
|||||||
|
|
||||||
std::string tooltip;
|
std::string tooltip;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Negative coordinate means out of the window, likely because the window was deactivated.
|
// Negative coordinate means out of the window, likely because the window was deactivated.
|
||||||
// In that case the tooltip should be hidden.
|
// In that case the tooltip should be hidden.
|
||||||
if (m_mouse.position.x() >= 0. && m_mouse.position.y() >= 0.) {
|
if (m_mouse.position.x() >= 0. && m_mouse.position.y() >= 0.) {
|
||||||
@ -1745,7 +1741,7 @@ void GLCanvas3D::render()
|
|||||||
|
|
||||||
#if ENABLE_RENDER_STATISTICS
|
#if ENABLE_RENDER_STATISTICS
|
||||||
auto end_time = std::chrono::high_resolution_clock::now();
|
auto end_time = std::chrono::high_resolution_clock::now();
|
||||||
m_render_stats.last_frame = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count();
|
m_render_stats.add_frame(std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count());
|
||||||
#endif // ENABLE_RENDER_STATISTICS
|
#endif // ENABLE_RENDER_STATISTICS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,11 +320,22 @@ class GLCanvas3D
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if ENABLE_RENDER_STATISTICS
|
#if ENABLE_RENDER_STATISTICS
|
||||||
struct RenderStats
|
class RenderStats
|
||||||
{
|
{
|
||||||
long long last_frame;
|
std::queue<std::pair<long long, long long>> m_frames;
|
||||||
|
long long m_curr_total{ 0 };
|
||||||
|
|
||||||
RenderStats() : last_frame(0) {}
|
public:
|
||||||
|
void add_frame(long long frame) {
|
||||||
|
long long now = wxGetLocalTimeMillis().GetValue();
|
||||||
|
if (!m_frames.empty() && now - m_frames.front().first > 1000) {
|
||||||
|
m_curr_total -= m_frames.front().second;
|
||||||
|
m_frames.pop();
|
||||||
|
}
|
||||||
|
m_curr_total += frame;
|
||||||
|
m_frames.push({ now, frame });
|
||||||
|
}
|
||||||
|
long long get_average() const { return m_frames.empty() ? 0 : m_curr_total / m_frames.size(); }
|
||||||
};
|
};
|
||||||
#endif // ENABLE_RENDER_STATISTICS
|
#endif // ENABLE_RENDER_STATISTICS
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user