mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
ENABLE_RENDER_STATISTICS -> FPS averaged to last second
This commit is contained in:
parent
1185ec9d2a
commit
bf3786be59
2 changed files with 23 additions and 16 deletions
|
@ -320,11 +320,22 @@ class GLCanvas3D
|
|||
};
|
||||
|
||||
#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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue