Optimize mem plot reconstruction loop.

This commit is contained in:
Bartosz Taudul 2018-04-30 13:44:44 +02:00
parent 76f0c8fafe
commit 553e3ca38b

View File

@ -1955,27 +1955,40 @@ void Worker::ReconstructMemAllocPlot()
ptr->val = 0;
ptr++;
while( aptr != aend && fptr != fend )
if( aptr != aend && fptr != fend )
{
int64_t time;
if( aptr->timeAlloc < fptr->time )
auto atime = aptr->timeAlloc;
auto ftime = fptr->time;
for(;;)
{
if( atime < ftime )
{
time = aptr->timeAlloc;
usage += int64_t( aptr->size );
assert( usage >= 0 );
if( max < usage ) max = usage;
ptr->time = atime;
ptr->val = usage;
ptr++;
aptr++;
if( aptr == aend ) break;
atime = aptr->timeAlloc;
}
else
{
time = fptr->time;
usage -= fptr->size;
fptr++;
}
assert( usage >= 0 );
if( max < usage ) max = usage;
ptr->time = time;
ptr->time = ftime;
ptr->val = usage;
ptr++;
fptr++;
if( fptr == fend ) break;
ftime = fptr->time;
}
}
}
while( aptr != aend )
{
assert( aptr->timeFree < 0 );