MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / tick

Method tick

source/core/StarTickRateMonitor.cpp:19–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19double TickRateMonitor::tick(unsigned count) {
20 double currentTime = Time::monotonicTime();
21
22 if (m_lastTick > currentTime) {
23 m_lastTick = currentTime - m_window;
24 m_ticks = 0;
25 } else if (m_lastTick < currentTime) {
26 double timePast = currentTime - m_lastTick;
27 double rate = m_ticks / m_window;
28 m_ticks = max(0.0, m_ticks - timePast * rate);
29 m_lastTick = currentTime;
30 }
31
32 m_ticks += count;
33
34 return m_ticks / m_window;
35}
36
37double TickRateMonitor::rate() const {
38 return TickRateMonitor(*this).tick(0);

Callers 1

rateMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected