mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Optimize calculation of standard deviation.
This commit is contained in:
parent
f57cac9042
commit
a0299cc63a
@ -6029,14 +6029,10 @@ void View::DrawFindZone()
|
||||
TextFocused( "Median time:", TimeToString( m_findZone.median ) );
|
||||
if( m_findZone.sorted.size() > 1 )
|
||||
{
|
||||
const auto sz = m_findZone.sorted.size();
|
||||
const auto avg = m_findZone.average;
|
||||
double ss = 0;
|
||||
for( auto& v : m_findZone.sorted )
|
||||
{
|
||||
const auto d = double( v ) - avg;
|
||||
ss += d*d;
|
||||
}
|
||||
const auto sd = sqrt( ss / ( m_findZone.sorted.size() - 1 ) );
|
||||
const auto ss = zoneData.sumSq - 2. * zoneData.total * avg + avg * avg * sz;
|
||||
const auto sd = sqrt( ss / ( sz - 1 ) );
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::Spacing();
|
||||
|
@ -2590,6 +2590,7 @@ void Worker::ProcessZoneEnd( const QueueZoneEnd& ev )
|
||||
slz.min = std::min( slz.min, timeSpan );
|
||||
slz.max = std::max( slz.max, timeSpan );
|
||||
slz.total += timeSpan;
|
||||
slz.sumSq += double( timeSpan ) * timeSpan;
|
||||
if( zone->child >= 0 )
|
||||
{
|
||||
for( auto& v : GetZoneChildren( zone->child ) )
|
||||
@ -3587,6 +3588,7 @@ void Worker::ReadTimelineUpdateStatistics( ZoneEvent* zone, uint16_t thread )
|
||||
slz.min = std::min( slz.min, timeSpan );
|
||||
slz.max = std::max( slz.max, timeSpan );
|
||||
slz.total += timeSpan;
|
||||
slz.sumSq += double( timeSpan ) * timeSpan;
|
||||
if( zone->child >= 0 )
|
||||
{
|
||||
for( auto& v : GetZoneChildren( zone->child ) )
|
||||
|
@ -86,6 +86,7 @@ private:
|
||||
int64_t min = std::numeric_limits<int64_t>::max();
|
||||
int64_t max = std::numeric_limits<int64_t>::min();
|
||||
int64_t total = 0;
|
||||
double sumSq = 0;
|
||||
int64_t selfMin = std::numeric_limits<int64_t>::max();
|
||||
int64_t selfMax = std::numeric_limits<int64_t>::min();
|
||||
int64_t selfTotal = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user