mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Optimize creation of vector of frees.
This commit is contained in:
parent
3eb73b8d43
commit
e5cb241c19
@ -1900,19 +1900,25 @@ void Worker::CreateMemAllocPlot()
|
|||||||
|
|
||||||
void Worker::ReconstructMemAllocPlot()
|
void Worker::ReconstructMemAllocPlot()
|
||||||
{
|
{
|
||||||
Vector<std::pair<int64_t, double>> frees;
|
struct FreeData
|
||||||
|
{
|
||||||
|
int64_t time;
|
||||||
|
double size;
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector<FreeData> frees;
|
||||||
frees.reserve( m_data.memory.data.size() );
|
frees.reserve( m_data.memory.data.size() );
|
||||||
for( auto& v : m_data.memory.data )
|
for( auto& v : m_data.memory.data )
|
||||||
{
|
{
|
||||||
if( v.timeFree >= 0 )
|
if( v.timeFree >= 0 )
|
||||||
{
|
{
|
||||||
auto& f = frees.push_next_no_space_check();
|
auto& f = frees.push_next_no_space_check();
|
||||||
f.first = v.timeFree;
|
f.time = v.timeFree;
|
||||||
f.second = double( v.size );
|
f.size = double( int64_t( v.size ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pdqsort_branchless( frees.begin(), frees.end(), [] ( const auto& lhs, const auto& rhs ) { return lhs.first < rhs.first; } );
|
pdqsort_branchless( frees.begin(), frees.end(), [] ( const auto& lhs, const auto& rhs ) { return lhs.time < rhs.time; } );
|
||||||
|
|
||||||
const auto psz = m_data.memory.data.size() + frees.size() + 1;
|
const auto psz = m_data.memory.data.size() + frees.size() + 1;
|
||||||
|
|
||||||
@ -1942,7 +1948,7 @@ void Worker::ReconstructMemAllocPlot()
|
|||||||
while( aptr != aend && fptr != fend )
|
while( aptr != aend && fptr != fend )
|
||||||
{
|
{
|
||||||
int64_t time;
|
int64_t time;
|
||||||
if( aptr->timeAlloc < fptr->first )
|
if( aptr->timeAlloc < fptr->time )
|
||||||
{
|
{
|
||||||
time = aptr->timeAlloc;
|
time = aptr->timeAlloc;
|
||||||
usage += int64_t( aptr->size );
|
usage += int64_t( aptr->size );
|
||||||
@ -1950,8 +1956,8 @@ void Worker::ReconstructMemAllocPlot()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
time = fptr->first;
|
time = fptr->time;
|
||||||
usage -= fptr->second;
|
usage -= fptr->size;
|
||||||
fptr++;
|
fptr++;
|
||||||
}
|
}
|
||||||
assert( usage >= 0 );
|
assert( usage >= 0 );
|
||||||
@ -1974,8 +1980,8 @@ void Worker::ReconstructMemAllocPlot()
|
|||||||
}
|
}
|
||||||
while( fptr != fend )
|
while( fptr != fend )
|
||||||
{
|
{
|
||||||
int64_t time = fptr->first;
|
int64_t time = fptr->time;
|
||||||
usage -= fptr->second;
|
usage -= fptr->size;
|
||||||
assert( usage >= 0 );
|
assert( usage >= 0 );
|
||||||
assert( max >= usage );
|
assert( max >= usage );
|
||||||
ptr->time = time;
|
ptr->time = time;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user