mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
Add outlier removal to frame time histogram.
This commit is contained in:
parent
b1f49d4c69
commit
099933e66d
@ -8608,8 +8608,8 @@ void View::DrawInfo()
|
|||||||
const auto ty = ImGui::GetFontSize();
|
const auto ty = ImGui::GetFontSize();
|
||||||
|
|
||||||
auto& frames = m_frameSortData.data;
|
auto& frames = m_frameSortData.data;
|
||||||
const auto tmin = frames.front();
|
auto tmin = frames.front();
|
||||||
const auto tmax = frames.back();
|
auto tmax = frames.back();
|
||||||
|
|
||||||
if( tmin != std::numeric_limits<int64_t>::max() )
|
if( tmin != std::numeric_limits<int64_t>::max() )
|
||||||
{
|
{
|
||||||
@ -8617,6 +8617,12 @@ void View::DrawInfo()
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Checkbox( "Log time", &m_frameSortData.logTime );
|
ImGui::Checkbox( "Log time", &m_frameSortData.logTime );
|
||||||
|
|
||||||
|
TextDisabledUnformatted( "Minimum values in bin:" );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::SetNextItemWidth( ImGui::CalcTextSize( "123456890123456" ).x );
|
||||||
|
ImGui::InputInt( "##minBinVal", &m_frameSortData.minBinVal );
|
||||||
|
if( m_frameSortData.minBinVal < 1 ) m_frameSortData.minBinVal = 1;
|
||||||
|
|
||||||
TextDisabledUnformatted( "Time range:" );
|
TextDisabledUnformatted( "Time range:" );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text( "%s - %s (%s)", TimeToString( tmin ), TimeToString( tmax ), TimeToString( tmax - tmin ) );
|
ImGui::Text( "%s - %s (%s)", TimeToString( tmin ), TimeToString( tmax ), TimeToString( tmax - tmin ) );
|
||||||
@ -8625,8 +8631,7 @@ void View::DrawInfo()
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text( "%s FPS - %s FPS", RealToString( round( 1000000000.0 / tmin ), true ), RealToString( round( 1000000000.0 / tmax ), true ) );
|
ImGui::Text( "%s FPS - %s FPS", RealToString( round( 1000000000.0 / tmin ), true ), RealToString( round( 1000000000.0 / tmax ), true ) );
|
||||||
|
|
||||||
const auto dt = double( tmax - tmin );
|
if( tmax - tmin > 0 )
|
||||||
if( dt > 0 )
|
|
||||||
{
|
{
|
||||||
const auto w = ImGui::GetContentRegionAvail().x;
|
const auto w = ImGui::GetContentRegionAvail().x;
|
||||||
|
|
||||||
@ -8643,34 +8648,86 @@ void View::DrawInfo()
|
|||||||
|
|
||||||
memset( bins.get(), 0, sizeof( int64_t ) * numBins );
|
memset( bins.get(), 0, sizeof( int64_t ) * numBins );
|
||||||
|
|
||||||
|
auto framesBegin = frames.begin();
|
||||||
|
auto framesEnd = frames.end();
|
||||||
|
while( framesBegin != framesEnd && *framesBegin == 0 ) ++framesBegin;
|
||||||
|
|
||||||
|
if( m_frameSortData.minBinVal > 1 )
|
||||||
|
{
|
||||||
if( m_frameSortData.logTime )
|
if( m_frameSortData.logTime )
|
||||||
{
|
{
|
||||||
const auto tMinLog = log10( tmin );
|
const auto tMinLog = log10( tmin );
|
||||||
const auto zmax = ( log10( tmax ) - tMinLog ) / numBins;
|
const auto zmax = ( log10( tmax ) - tMinLog ) / numBins;
|
||||||
auto fit = frames.begin();
|
int64_t i;
|
||||||
while( fit != frames.end() && *fit == 0 ) ++fit;
|
for( i=0; i<numBins; i++ )
|
||||||
for( int64_t i=0; i<numBins; i++ )
|
|
||||||
{
|
{
|
||||||
const auto nextBinVal = int64_t( pow( 10.0, tMinLog + ( i+1 ) * zmax ) );
|
const auto nextBinVal = int64_t( pow( 10.0, tMinLog + ( i+1 ) * zmax ) );
|
||||||
auto nit = std::lower_bound( fit, frames.end(), nextBinVal );
|
auto nit = std::lower_bound( framesBegin, framesEnd, nextBinVal );
|
||||||
bins[i] = std::distance( fit, nit );
|
const auto distance = std::distance( framesBegin, nit );
|
||||||
fit = nit;
|
if( distance >= m_frameSortData.minBinVal ) break;
|
||||||
|
framesBegin = nit;
|
||||||
|
}
|
||||||
|
for( int64_t j=numBins-1; j>i; j-- )
|
||||||
|
{
|
||||||
|
const auto nextBinVal = int64_t( pow( 10.0, tMinLog + ( j-1 ) * zmax ) );
|
||||||
|
auto nit = std::lower_bound( framesBegin, framesEnd, nextBinVal );
|
||||||
|
const auto distance = std::distance( nit, framesEnd );
|
||||||
|
if( distance >= m_frameSortData.minBinVal ) break;
|
||||||
|
framesEnd = nit;
|
||||||
}
|
}
|
||||||
bins[numBins-1] += std::distance( fit, frames.end() );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto zmax = tmax - tmin;
|
const auto zmax = tmax - tmin;
|
||||||
auto fit = frames.begin();
|
int64_t i;
|
||||||
while( fit != frames.end() && *fit == 0 ) ++fit;
|
for( i=0; i<numBins; i++ )
|
||||||
for( int64_t i=0; i<numBins; i++ )
|
|
||||||
{
|
{
|
||||||
const auto nextBinVal = tmin + ( i+1 ) * zmax / numBins;
|
const auto nextBinVal = tmin + ( i+1 ) * zmax / numBins;
|
||||||
auto nit = std::lower_bound( fit, frames.end(), nextBinVal );
|
auto nit = std::lower_bound( framesBegin, framesEnd, nextBinVal );
|
||||||
|
const auto distance = std::distance( framesBegin, nit );
|
||||||
|
if( distance >= m_frameSortData.minBinVal ) break;
|
||||||
|
framesBegin = nit;
|
||||||
|
}
|
||||||
|
for( int64_t j=numBins-1; j>i; j-- )
|
||||||
|
{
|
||||||
|
const auto nextBinVal = tmin + ( j-1 ) * zmax / numBins;
|
||||||
|
auto nit = std::lower_bound( framesBegin, framesEnd, nextBinVal );
|
||||||
|
const auto distance = std::distance( nit, framesEnd );
|
||||||
|
if( distance >= m_frameSortData.minBinVal ) break;
|
||||||
|
framesEnd = nit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tmin = *framesBegin;
|
||||||
|
tmax = *(framesEnd-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_frameSortData.logTime )
|
||||||
|
{
|
||||||
|
const auto tMinLog = log10( tmin );
|
||||||
|
const auto zmax = ( log10( tmax ) - tMinLog ) / numBins;
|
||||||
|
auto fit = framesBegin;
|
||||||
|
for( int64_t i=0; i<numBins; i++ )
|
||||||
|
{
|
||||||
|
const auto nextBinVal = int64_t( pow( 10.0, tMinLog + ( i+1 ) * zmax ) );
|
||||||
|
auto nit = std::lower_bound( fit, framesEnd, nextBinVal );
|
||||||
bins[i] = std::distance( fit, nit );
|
bins[i] = std::distance( fit, nit );
|
||||||
fit = nit;
|
fit = nit;
|
||||||
}
|
}
|
||||||
bins[numBins-1] += std::distance( fit, frames.end() );
|
bins[numBins-1] += std::distance( fit, framesEnd );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto zmax = tmax - tmin;
|
||||||
|
auto fit = framesBegin;
|
||||||
|
for( int64_t i=0; i<numBins; i++ )
|
||||||
|
{
|
||||||
|
const auto nextBinVal = tmin + ( i+1 ) * zmax / numBins;
|
||||||
|
auto nit = std::lower_bound( fit, framesEnd, nextBinVal );
|
||||||
|
bins[i] = std::distance( fit, nit );
|
||||||
|
fit = nit;
|
||||||
|
}
|
||||||
|
bins[numBins-1] += std::distance( fit, framesEnd );
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t maxVal = bins[0];
|
int64_t maxVal = bins[0];
|
||||||
@ -8778,7 +8835,7 @@ void View::DrawInfo()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto pxns = numBins / dt;
|
const auto pxns = numBins / ( tmax - tmin );
|
||||||
const auto nspx = 1.0 / pxns;
|
const auto nspx = 1.0 / pxns;
|
||||||
const auto scale = std::max<float>( 0.0f, round( log10( nspx ) + 2 ) );
|
const auto scale = std::max<float>( 0.0f, round( log10( nspx ) + 2 ) );
|
||||||
const auto step = pow( 10, scale );
|
const auto step = pow( 10, scale );
|
||||||
|
@ -507,6 +507,7 @@ private:
|
|||||||
bool drawAvgMed = true;
|
bool drawAvgMed = true;
|
||||||
bool limitToView = false;
|
bool limitToView = false;
|
||||||
std::pair<int, int> limitRange = { -1, 0 };
|
std::pair<int, int> limitRange = { -1, 0 };
|
||||||
|
int minBinVal = 1;
|
||||||
} m_frameSortData;
|
} m_frameSortData;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user