Display P75, P90, P99 and P99.9 for frame statistics.

This commit is contained in:
Bartosz Taudul
2026-06-24 20:09:03 +02:00
parent a237b009ec
commit f700597067
2 changed files with 35 additions and 1 deletions

View File

@@ -951,6 +951,10 @@ private:
int minBinVal = 1;
double sumSq = 0;
float sd = 0;
int64_t p75 = 0;
int64_t p90 = 0;
int64_t p99 = 0;
int64_t p99_9 = 0;
} m_frameSortData;
struct {

View File

@@ -115,8 +115,13 @@ void View::DrawFrameStatistics()
if( recalc )
{
auto& vec = m_frameSortData.data;
auto Percentile = [&vec, vsz]( double p ) { return vec[std::min<size_t>( vsz - 1, p * vsz )]; };
m_frameSortData.average = float( total ) / vsz;
m_frameSortData.median = vec[vsz/2];
m_frameSortData.median = Percentile( 0.5 );
m_frameSortData.p75 = Percentile( 0.75 );
m_frameSortData.p90 = Percentile( 0.9 );
m_frameSortData.p99 = Percentile( 0.99 );
m_frameSortData.p99_9 = Percentile( 0.999 );
m_frameSortData.total = total;
m_frameSortData.sumSq = sumSq;
m_frameSortData.frameNum = fsz;
@@ -350,6 +355,31 @@ void View::DrawFrameStatistics()
ImGui::TextDisabled( "(%.2f%%)", 100.f * m_frameSortData.sd / m_frameSortData.average );
TooltipIfHovered( "Coefficient of variation" );
constexpr auto PercentileLine = []( const char* label, int64_t t ) {
TextFocused( label, TimeToString( t ) );
ImGui::SameLine();
ImGui::TextDisabled( "(%s FPS)", RealToString( round( 1000000000.0 / t ) ) );
if( ImGui::IsItemHovered() )
{
ImGui::BeginTooltip();
ImGui::Text( "%s FPS", RealToString( 1000000000.0 / t ) );
ImGui::EndTooltip();
}
};
PercentileLine( "P75:", m_frameSortData.p75 );
ImGui::SameLine();
ImGui::Spacing();
ImGui::SameLine();
PercentileLine( "P90:", m_frameSortData.p90 );
ImGui::SameLine();
ImGui::Spacing();
ImGui::SameLine();
PercentileLine( "P99:", m_frameSortData.p99 );
ImGui::SameLine();
ImGui::Spacing();
ImGui::SameLine();
PercentileLine( "P99.9:", m_frameSortData.p99_9 );
ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) );
ImGui::Checkbox( "###draw1", &m_frameSortData.drawAvgMed );
ImGui::SameLine();