mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-02-16 10:41:01 +00:00
add total calls to stats
This commit is contained in:
@@ -22,6 +22,7 @@ struct Stats {
|
||||
double min;
|
||||
double max;
|
||||
size_t n;
|
||||
size_t total_calls;
|
||||
};
|
||||
|
||||
/// Calculates and stores the moving average over K samples of execution time data
|
||||
@@ -41,6 +42,7 @@ struct UnitExecutionTime {
|
||||
|
||||
private:
|
||||
boost::synchronized_value<boost::circular_buffer<Duration>> m_measurements;
|
||||
size_t m_total_calls {};
|
||||
};
|
||||
|
||||
/// Holds profiles for multiple units by name. Threadsafe.
|
||||
|
||||
@@ -52,11 +52,13 @@ prof::Stats prof::UnitExecutionTime::stats() const {
|
||||
result.stddev += std::pow(measurement.count() - result.mean, 2);
|
||||
}
|
||||
result.stddev = std::sqrt(result.stddev / double(measurements->size()));
|
||||
result.total_calls = m_total_calls;
|
||||
return result;
|
||||
}
|
||||
|
||||
void prof::UnitExecutionTime::add_sample(const Duration& dur) {
|
||||
m_measurements->push_back(dur);
|
||||
++m_total_calls;
|
||||
}
|
||||
|
||||
prof::UnitExecutionTime::UnitExecutionTime()
|
||||
|
||||
@@ -860,6 +860,7 @@ TLuaEngine::StateThreadData::StateThreadData(const std::string& Name, TLuaStateI
|
||||
Result[name]["min"] = stat.min;
|
||||
Result[name]["max"] = stat.max;
|
||||
Result[name]["n"] = stat.n;
|
||||
Result[name]["total_calls"] = stat.total_calls;
|
||||
}
|
||||
return Result;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user