From ca0b9a3753fa3b42d4ac8183adcf30d957f55016 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Tue, 9 Nov 2021 20:25:25 +0000 Subject: SL-16329 - track frame time and jitter (as average deviation frame to frame) in stats window --- indra/llcommon/lltracerecording.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/lltracerecording.cpp') diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index c72a64d086..5ce1b337fe 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -858,7 +858,6 @@ F64 PeriodicRecording::getPeriodMean( const StatType& stat, S3 : NaN; } - F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { LL_PROFILE_ZONE_SCOPED; @@ -952,6 +951,32 @@ F64 PeriodicRecording::getPeriodMean( const StatType& stat, S : NaN; } +F64 PeriodicRecording::getPeriodMedian( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) +{ + LL_PROFILE_ZONE_SCOPED; + num_periods = llmin(num_periods, getNumRecordedPeriods()); + + std::vector buf; + for (S32 i = 1; i <= num_periods; i++) + { + Recording& recording = getPrevRecording(i); + if (recording.getDuration() > (F32Seconds)0.f) + { + if (recording.hasValue(stat)) + { + buf.push_back(recording.getMean(stat)); + } + } + } + if (buf.size()==0) + { + return 0.0f; + } + std::sort(buf.begin(), buf.end()); + + return F64((buf.size() % 2 == 0) ? (buf[buf.size() / 2 - 1] + buf[buf.size() / 2]) / 2 : buf[buf.size() / 2]); +} + F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { LL_PROFILE_ZONE_SCOPED; -- cgit v1.2.3