1
0
镜像自地址 https://github.com/luanti-org/luanti.git 已同步 2026-01-09 18:55:36 +01:00

Fix profiler assertion failures

oops
这个提交包含在:
sfan5
2024-04-20 14:32:35 +02:00
父节点 b7887a339d
当前提交 3bd5169aee
修改 2 个文件,包含 8 行新增2 行删除

查看文件

@@ -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;
}