1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

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.
This commit is contained in:
Bartosz Taudul 2017-10-21 13:32:51 +02:00
parent 75e3dd175a
commit c28b3a420f
2 changed files with 4 additions and 0 deletions

View File

@ -6,6 +6,7 @@
#include <algorithm>
#include <assert.h>
#include <chrono>
#include <inttypes.h>
#include <limits>
#include <math.h>
@ -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::milliseconds>( 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::milliseconds>( 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; } );

View File

@ -101,6 +101,7 @@ private:
bool enabled;
Vector<PlotItem*> data;
Vector<PlotItem*> postpone;
uint64_t postponeTime;
};
void Worker();