From c28b3a420f2674a30da68654de3abc2c11a41b52 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 21 Oct 2017 13:32:51 +0200 Subject: [PATCH] Delay insertion of postponed plot items. This further reduces number of memmoves that need to be performed on a vector, which results in net increased throughput. --- server/TracyView.cpp | 3 +++ server/TracyView.hpp | 1 + 2 files changed, 4 insertions(+) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index a7c86335..ae587596 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -1042,6 +1043,7 @@ void View::InsertPlot( PlotData* plot, PlotItem* item ) { 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::high_resolution_clock::now().time_since_epoch() ).count(); plot->postpone.push_back( item ); } } @@ -1082,6 +1084,7 @@ void View::HandlePostponedPlots() { auto& src = plot->postpone; if( src.empty() ) continue; + if( std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch() ).count() - plot->postponeTime < 100 ) continue; auto& dst = plot->data; std::sort( src.begin(), src.end(), [] ( const auto& l, const auto& r ) { return l->time < r->time; } ); const auto ds = std::lower_bound( dst.begin(), dst.end(), src.front()->time, [] ( const auto& l, const auto& r ) { return l->time < r; } ); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 97b41002..d07e04d0 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -101,6 +101,7 @@ private: bool enabled; Vector data; Vector postpone; + uint64_t postponeTime; }; void Worker();