mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 07:54:36 +00:00
Use SortedVector for plot data.
This commit is contained in:
parent
90c873421c
commit
417d526581
@ -9,6 +9,7 @@
|
||||
|
||||
#include "TracyCharUtil.hpp"
|
||||
#include "TracyShortPtr.hpp"
|
||||
#include "TracySortedVector.hpp"
|
||||
#include "TracyVector.hpp"
|
||||
#include "tracy_robin_hood.h"
|
||||
#include "../common/TracyForceInline.hpp"
|
||||
@ -636,12 +637,12 @@ enum class PlotValueFormatting : uint8_t
|
||||
|
||||
struct PlotData
|
||||
{
|
||||
struct PlotItemSort { bool operator()( const PlotItem& lhs, const PlotItem& rhs ) { return lhs.time.Val() < rhs.time.Val(); }; };
|
||||
|
||||
uint64_t name;
|
||||
double min;
|
||||
double max;
|
||||
Vector<PlotItem> data;
|
||||
Vector<PlotItem> postpone;
|
||||
uint64_t postponeTime;
|
||||
SortedVector<PlotItem, PlotItemSort> data;
|
||||
PlotType type;
|
||||
PlotValueFormatting format;
|
||||
};
|
||||
|
@ -6196,6 +6196,7 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
||||
|
||||
for( const auto& v : m_worker.GetPlots() )
|
||||
{
|
||||
assert( v->data.is_sorted() );
|
||||
auto& vis = Vis( v );
|
||||
if( !vis.visible )
|
||||
{
|
||||
|
@ -3924,25 +3924,11 @@ void Worker::InsertPlot( PlotData* plot, int64_t time, double val )
|
||||
plot->max = val;
|
||||
plot->data.push_back( { Int48( time ), val } );
|
||||
}
|
||||
else if( plot->data.back().time.Val() < time )
|
||||
{
|
||||
if( plot->min > val ) plot->min = val;
|
||||
else if( plot->max < val ) plot->max = val;
|
||||
plot->data.push_back_non_empty( { Int48( time ), val } );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( plot->min > val ) plot->min = val;
|
||||
else if( plot->max < val ) plot->max = val;
|
||||
if( plot->postpone.empty() )
|
||||
{
|
||||
plot->postponeTime = std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
|
||||
plot->postpone.push_back( { Int48( time ), val } );
|
||||
}
|
||||
else
|
||||
{
|
||||
plot->postpone.push_back_non_empty( { Int48( time ), val } );
|
||||
}
|
||||
plot->data.push_back( { Int48( time ), val } );
|
||||
}
|
||||
}
|
||||
|
||||
@ -3971,22 +3957,7 @@ void Worker::HandlePostponedPlots()
|
||||
{
|
||||
for( auto& plot : m_data.plots.Data() )
|
||||
{
|
||||
auto& src = plot->postpone;
|
||||
if( src.empty() ) continue;
|
||||
if( std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count() - plot->postponeTime < 100 ) continue;
|
||||
auto& dst = plot->data;
|
||||
#ifdef NO_PARALLEL_SORT
|
||||
pdqsort_branchless( src.begin(), src.end(), [] ( const auto& l, const auto& r ) { return l.time.Val() < r.time.Val(); } );
|
||||
#else
|
||||
std::sort( std::execution::par_unseq, src.begin(), src.end(), [] ( const auto& l, const auto& r ) { return l.time.Val() < r.time.Val(); } );
|
||||
#endif
|
||||
const auto ds = std::lower_bound( dst.begin(), dst.end(), src.front().time.Val(), [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
||||
const auto dsd = std::distance( dst.begin(), ds ) ;
|
||||
const auto de = std::lower_bound( ds, dst.end(), src.back().time.Val(), [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
||||
const auto ded = std::distance( dst.begin(), de );
|
||||
dst.insert( de, src.begin(), src.end() );
|
||||
std::inplace_merge( dst.begin() + dsd, dst.begin() + ded, dst.begin() + ded + src.size(), [] ( const auto& l, const auto& r ) { return l.time.Val() < r.time.Val(); } );
|
||||
src.clear();
|
||||
if( !plot->data.is_sorted() ) plot->data.sort();
|
||||
}
|
||||
}
|
||||
|
||||
@ -6057,7 +6028,7 @@ void Worker::ProcessSysTime( const QueueSysTime& ev )
|
||||
assert( m_sysTimePlot->data.back().time.Val() <= time );
|
||||
if( m_sysTimePlot->min > val ) m_sysTimePlot->min = val;
|
||||
else if( m_sysTimePlot->max < val ) m_sysTimePlot->max = val;
|
||||
m_sysTimePlot->data.push_back_non_empty( { time, val } );
|
||||
m_sysTimePlot->data.push_back( { time, val } );
|
||||
}
|
||||
}
|
||||
|
||||
@ -6225,7 +6196,7 @@ void Worker::MemAllocChanged( uint64_t memname, MemData& memdata, int64_t time )
|
||||
assert( memdata.plot->data.back().time.Val() <= time );
|
||||
if( memdata.plot->min > val ) memdata.plot->min = val;
|
||||
else if( memdata.plot->max < val ) memdata.plot->max = val;
|
||||
memdata.plot->data.push_back_non_empty( { time, val } );
|
||||
memdata.plot->data.push_back( { time, val } );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user