Durations of the last frames, and the frame rate they make.
More...
#include <aegis2d/render/metrics_overlay.hpp>
|
| using | Clock = std::chrono::steady_clock |
| | Clock of tick().
|
| |
|
| void | tick (Clock::time_point now) noexcept |
| | Records the frame that ends at now: the time since the previous tick().
|
| |
| void | record (double seconds) noexcept |
| | Records a frame of a given duration; the oldest one is dropped when full.
|
| |
| void | clear () noexcept |
| | Forgets every frame and the last tick().
|
| |
| std::size_t | size () const noexcept |
| | Number of frames kept.
|
| |
| double | frame_ms (std::size_t index) const |
| | Duration of a frame kept.
|
| |
| double | last_ms () const noexcept |
| | Duration of the newest frame.
|
| |
| double | average_ms () const noexcept |
| | Mean duration of the frames kept.
|
| |
| double | worst_ms () const noexcept |
| | Longest of the frames kept.
|
| |
| double | fps () const noexcept |
| | Frames per second over the last second.
|
| |
|
| static constexpr std::size_t | capacity = 120 |
| | Number of frames kept: two seconds at 60 frames per second.
|
| |
Durations of the last frames, and the frame rate they make.
The game calls tick() once a frame; the metrics keep the last capacity frames, oldest first.
◆ Clock
◆ average_ms()
| double aegis2d::render::FrameMetrics::average_ms |
( |
| ) |
const |
|
noexcept |
Mean duration of the frames kept.
- Returns
- In milliseconds; 0 without any frame.
◆ clear()
| void aegis2d::render::FrameMetrics::clear |
( |
| ) |
|
|
noexcept |
Forgets every frame and the last tick().
◆ fps()
| double aegis2d::render::FrameMetrics::fps |
( |
| ) |
const |
|
noexcept |
Frames per second over the last second.
- Returns
- The newest frames that make up one second (all of them if they make less), divided by their total duration; 0 without any frame or time.
◆ frame_ms()
| double aegis2d::render::FrameMetrics::frame_ms |
( |
std::size_t |
index | ) |
const |
Duration of a frame kept.
- Parameters
-
| index | 0 for the oldest, size() - 1 for the newest. |
- Returns
- Its duration in milliseconds.
- Exceptions
-
| std::out_of_range | if index is not below size(). |
◆ last_ms()
| double aegis2d::render::FrameMetrics::last_ms |
( |
| ) |
const |
|
noexcept |
Duration of the newest frame.
- Returns
- In milliseconds; 0 without any frame.
◆ record()
| void aegis2d::render::FrameMetrics::record |
( |
double |
seconds | ) |
|
|
noexcept |
Records a frame of a given duration; the oldest one is dropped when full.
- Parameters
-
| seconds | Duration of the frame; a negative or not finite one counts as 0. |
◆ size()
| std::size_t aegis2d::render::FrameMetrics::size |
( |
| ) |
const |
|
noexcept |
Number of frames kept.
- Returns
- From 0 to
capacity.
◆ tick()
| void aegis2d::render::FrameMetrics::tick |
( |
Clock::time_point |
now | ) |
|
|
noexcept |
Records the frame that ends at now: the time since the previous tick().
The first call only starts counting.
- Parameters
-
| now | Time of the call, such as Clock::now(). |
◆ worst_ms()
| double aegis2d::render::FrameMetrics::worst_ms |
( |
| ) |
const |
|
noexcept |
Longest of the frames kept.
- Returns
- In milliseconds; 0 without any frame.
◆ capacity
| constexpr std::size_t aegis2d::render::FrameMetrics::capacity = 120 |
|
staticconstexpr |
Number of frames kept: two seconds at 60 frames per second.
The documentation for this class was generated from the following file: