Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorBartosz Taudul <wolf.pld@gmail.com>2021-02-07 17:52:08 +0300
committerBartosz Taudul <wolf.pld@gmail.com>2021-02-07 17:52:08 +0300
commit417d5265815692fb87127fba3f9446b6b2f17ebe (patch)
tree80710043b79d4b6e848cf94a54f05ad5cbfb339b /server
parent90c873421c2fccc0db1eac70bf4d0f45accec896 (diff)
Use SortedVector for plot data.
Diffstat (limited to 'server')
-rw-r--r--server/TracyEvent.hpp7
-rw-r--r--server/TracyView.cpp1
-rw-r--r--server/TracyWorker.cpp37
3 files changed, 9 insertions, 36 deletions
diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp
index e46333a9..23f876f8 100644
--- a/server/TracyEvent.hpp
+++ b/server/TracyEvent.hpp
@@ -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;
};
diff --git a/server/TracyView.cpp b/server/TracyView.cpp
index 009344b1..36dd9e0d 100644
--- a/server/TracyView.cpp
+++ b/server/TracyView.cpp
@@ -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 )
{
diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp
index 05f5a978..0c1e876b 100644
--- a/server/TracyWorker.cpp
+++ b/server/TracyWorker.cpp
@@ -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 } );
}
}