This util class provides an easy way to keep track of iterations per second for any body of code.
More...
#include <IPS.hpp>
|
| IPS () |
| Construct a new IPS object.
|
|
| ~IPS () |
| Construct a new IPS object.
|
|
IPS & | operator= (const IPS &OtherIPS) |
| Operator equals for IPS class.
|
|
void | Tick () |
| This method is used to update the iterations per second counter and recalculate all of the IPS metrics.
|
|
double | GetExactIPS () const |
| Accessor for the Current I P S private member. This method will return the immediate IPS since the last Tick() call. If called in a loop, this number will likely jump around greatly. If you want a 'smoother' IPS number then call the GetAverageIPS() method.
|
|
double | GetAverageIPS () const |
| Calculates the average iterations per second.
|
|
double | GetHighestIPS () const |
| Accessor for the Highest I P S private member.
|
|
double | GetLowestIPS () const |
| Accessor for the Lowest I P S private member.
|
|
double | Get1PercentLow () const |
| Accessor for the 1PercentLow I P S private member.
|
|
void | Reset () |
| Resets all metrics and frame time history.
|
|
|
void | UpdateMetrics () |
| This method is used to calculate the IPS stats. Highest, lowest, and 1 percent low IPS.
|
|
|
double | m_dCurrentIPS |
|
double | m_dHighestIPS |
|
double | m_dLowestIPS |
|
double | m_d1PercentLow |
|
std::deque< double > | m_dqIPSHistory |
|
std::chrono::high_resolution_clock::time_point | m_tLastUpdateTime |
|
const long unsigned int | m_nMaxMetricsHistorySize = 100 |
|
This util class provides an easy way to keep track of iterations per second for any body of code.
- Author
- ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
- Date
- 2023-08-17
◆ IPS()
◆ ~IPS()
◆ UpdateMetrics()
void IPS::UpdateMetrics |
( |
| ) |
|
|
inlineprivate |
This method is used to calculate the IPS stats. Highest, lowest, and 1 percent low IPS.
- Author
- ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
- Date
- 2023-08-17
52 {
53
54 if (m_dCurrentIPS > m_dHighestIPS)
55 {
56
57 m_dHighestIPS = m_dCurrentIPS;
58 }
59
60 if (m_dCurrentIPS < m_dLowestIPS)
61 {
62
63 m_dLowestIPS = m_dCurrentIPS;
64 }
65
66
67 m_dqIPSHistory.emplace_back(m_dCurrentIPS);
68
69
70 if (m_dqIPSHistory.size() > m_nMaxMetricsHistorySize)
71 {
72 m_dqIPSHistory.pop_front();
73 }
74
75 m_d1PercentLow = *std::min_element(m_dqIPSHistory.begin(), m_dqIPSHistory.end());
76 }
◆ operator=()
IPS & IPS::operator= |
( |
const IPS & |
OtherIPS | ) |
|
|
inline |
Operator equals for IPS class.
- Parameters
-
OtherIPS | - The IPS object to copy values from. |
- Returns
- IPS& - A reference to this object.
- Author
- clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
- Date
- 2023-10-10
118 {
119
120 m_dCurrentIPS = OtherIPS.m_dCurrentIPS;
121 m_dHighestIPS = OtherIPS.m_dHighestIPS;
122 m_dLowestIPS = OtherIPS.m_dLowestIPS;
123 m_d1PercentLow = OtherIPS.m_d1PercentLow;
124 m_dqIPSHistory = OtherIPS.m_dqIPSHistory;
125
126
127 return *this;
128 }
◆ Tick()
This method is used to update the iterations per second counter and recalculate all of the IPS metrics.
- Author
- ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
- Date
- 2023-08-17
139 {
140
141 std::chrono::time_point tCurrentTime = std::chrono::high_resolution_clock::now();
142 long int nElapsedTimeSinceLastTick = std::chrono::duration_cast<std::chrono::microseconds>(tCurrentTime - m_tLastUpdateTime).count();
143
144
145 m_dCurrentIPS = 1e6 / static_cast<double>(nElapsedTimeSinceLastTick);
146
147
149
150
151 m_tLastUpdateTime = tCurrentTime;
152 }
void UpdateMetrics()
This method is used to calculate the IPS stats. Highest, lowest, and 1 percent low IPS.
Definition IPS.hpp:51
◆ GetExactIPS()
double IPS::GetExactIPS |
( |
| ) |
const |
|
inline |
◆ GetAverageIPS()
double IPS::GetAverageIPS |
( |
| ) |
const |
|
inline |
Calculates the average iterations per second.
- Returns
- double - The average iterations per second according to the metrics window.
- Author
- ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
- Date
- 2023-08-17
181 {
182
183 if (m_dqIPSHistory.empty())
184 {
185
186 return 0.0;
187 }
188
189
190 double dSum = 0.0;
191 for (const double dVal : m_dqIPSHistory)
192 {
193
194 dSum += dVal;
195 }
196
197
198 return dSum / static_cast<double>(m_dqIPSHistory.size());
199 }
◆ GetHighestIPS()
double IPS::GetHighestIPS |
( |
| ) |
const |
|
inline |
◆ GetLowestIPS()
double IPS::GetLowestIPS |
( |
| ) |
const |
|
inline |
◆ Get1PercentLow()
double IPS::Get1PercentLow |
( |
| ) |
const |
|
inline |
◆ Reset()
The documentation for this class was generated from the following file: