mirror of
https://github.com/minetest/minetest.git
synced 2024-12-23 22:52:25 +01:00
Fix profiler assertion failures
oops
This commit is contained in:
parent
b7887a339d
commit
3bd5169aee
@ -96,7 +96,7 @@ void Profiler::avg(const std::string &name, float value)
|
||||
if (it == m_data.end()) {
|
||||
m_data.emplace(name, DataPair{value, 1});
|
||||
} else {
|
||||
assert(it->second.avgcount >= 1);
|
||||
assert(it->second.avgcount >= 0);
|
||||
it->second.value += value;
|
||||
it->second.avgcount++;
|
||||
}
|
||||
@ -106,7 +106,7 @@ void Profiler::clear()
|
||||
{
|
||||
MutexAutoLock lock(m_mutex);
|
||||
for (auto &it : m_data)
|
||||
it.second = DataPair();
|
||||
it.second.reset();
|
||||
m_start_time = porting::getTimeMs();
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,12 @@ private:
|
||||
float value = 0;
|
||||
int avgcount = 0;
|
||||
|
||||
inline void reset() {
|
||||
value = 0;
|
||||
// negative values are used for type checking, so leave them alone
|
||||
if (avgcount >= 1)
|
||||
avgcount = 0;
|
||||
}
|
||||
inline float getValue() const {
|
||||
return avgcount >= 1 ? (value / avgcount) : value;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user