Changeset View
Changeset View
Standalone View
Standalone View
frame_statistics.cpp
- This file was added.
1 | #include "frame_statistics.h" | ||||
---|---|---|---|---|---|
2 | | ||||
3 | namespace KWin | ||||
4 | { | ||||
5 | | ||||
6 | void FrameStatistics::addFrame() | ||||
7 | { | ||||
8 | m_frameTimes.push(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch())); | ||||
9 | if (m_frameTimes.size() > m_framesToKeep) { | ||||
10 | m_frameTimes.pop(); | ||||
11 | } | ||||
12 | } | ||||
13 | | ||||
14 | void FrameStatistics::reset() | ||||
15 | { | ||||
16 | while (!m_frameTimes.empty()) { | ||||
17 | m_frameTimes.pop(); | ||||
18 | } | ||||
19 | } | ||||
20 | | ||||
21 | std::size_t FrameStatistics::numberFrames() const | ||||
22 | { | ||||
23 | return m_frameTimes.size(); | ||||
24 | } | ||||
25 | | ||||
26 | std::chrono::milliseconds FrameStatistics::measuredTime() const | ||||
27 | { | ||||
28 | if (m_frameTimes.empty()) { | ||||
29 | return std::chrono::milliseconds::zero(); | ||||
30 | } | ||||
31 | return m_frameTimes.back() - m_frameTimes.front(); | ||||
32 | } | ||||
33 | | ||||
34 | } |