Read/write most of MemEvent in one go.

This commit is contained in:
Bartosz Taudul 2018-04-29 03:14:18 +02:00
parent d5f0f0939d
commit 9769cc4d7d
2 changed files with 5 additions and 9 deletions

View File

@ -143,8 +143,10 @@ struct MemEvent
uint64_t ptr;
uint64_t size;
int64_t timeAlloc;
uint16_t threadAlloc;
int64_t timeFree;
// All above is read/saved as-is.
uint16_t threadAlloc;
uint16_t threadFree;
};

View File

@ -520,10 +520,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
auto mem = m_data.memory.data.data();
for( uint64_t i=0; i<sz; i++ )
{
f.Read( &mem->ptr, sizeof( mem->ptr ) );
f.Read( &mem->size, sizeof( mem->size ) );
f.Read( &mem->timeAlloc, sizeof( mem->timeAlloc ) );
f.Read( &mem->timeFree, sizeof( mem->timeFree ) );
f.Read( mem, sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( MemEvent::timeAlloc ) + sizeof( MemEvent::timeFree ) );
uint64_t t[2];
f.Read( t, sizeof( t ) );
mem->threadAlloc = CompressThread( t[0] );
@ -2200,10 +2197,7 @@ void Worker::Write( FileWrite& f )
f.Write( &sz, sizeof( sz ) );
for( auto& mem : m_data.memory.data )
{
f.Write( &mem.ptr, sizeof( mem.ptr ) );
f.Write( &mem.size, sizeof( mem.size ) );
f.Write( &mem.timeAlloc, sizeof( mem.timeAlloc ) );
f.Write( &mem.timeFree, sizeof( mem.timeFree ) );
f.Write( &mem, sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( MemEvent::timeAlloc ) + sizeof( MemEvent::timeFree ) );
uint64_t t = DecompressThread( mem.threadAlloc );
f.Write( &t, sizeof( t ) );
t = DecompressThread( mem.threadFree );