mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
import-chrome: frame events
This commit is contained in:
parent
8b75a3fab0
commit
5dc29ba68d
@ -423,21 +423,46 @@ Worker::Worker( const char* name, const char* program, const std::vector<ImportE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unordered_map<std::string, uint64_t> frameNames;
|
||||||
|
|
||||||
for( auto& v : messages )
|
for( auto& v : messages )
|
||||||
{
|
{
|
||||||
auto msg = m_slab.Alloc<MessageData>();
|
// There is no specific chrome-tracing type for frame events. We use messages that contain the word "frame"
|
||||||
msg->time = v.timestamp;
|
std::string lower(v.message);
|
||||||
msg->ref = StringRef( StringRef::Type::Idx, StoreString( v.message.c_str(), v.message.size() ).idx );
|
std::transform(lower.begin(), lower.end(), lower.begin(), std::tolower);
|
||||||
msg->thread = CompressThread( v.tid );
|
if (lower.find("frame") != std::string::npos)
|
||||||
msg->color = 0xFFFFFFFF;
|
|
||||||
msg->callstack.SetVal( 0 );
|
|
||||||
|
|
||||||
if( m_threadCtx != v.tid )
|
|
||||||
{
|
{
|
||||||
m_threadCtx = v.tid;
|
// Reserve 0 as the default FrameSet, since it replaces the name with "Frame" and we want to keep our custom names.
|
||||||
m_threadCtxData = nullptr;
|
auto result = frameNames.emplace(v.message, frameNames.size() + 1);
|
||||||
|
auto fd = m_data.frames.Retrieve(result.first->second, [&](uint64_t name) {
|
||||||
|
auto fd = m_slab.AllocInit<FrameData>();
|
||||||
|
fd->name = name;
|
||||||
|
fd->continuous = 1;
|
||||||
|
return fd;
|
||||||
|
}, [&] (uint64_t name) {
|
||||||
|
HandleFrameName( name, v.message.c_str(), v.message.length() );
|
||||||
|
});
|
||||||
|
|
||||||
|
int64_t time = v.timestamp;
|
||||||
|
fd->frames.push_back(FrameEvent{ time, -1, -1 });
|
||||||
|
if (m_data.lastTime < time) m_data.lastTime = time;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto msg = m_slab.Alloc<MessageData>();
|
||||||
|
msg->time = v.timestamp;
|
||||||
|
msg->ref = StringRef( StringRef::Type::Idx, StoreString( v.message.c_str(), v.message.size() ).idx );
|
||||||
|
msg->thread = CompressThread( v.tid );
|
||||||
|
msg->color = 0xFFFFFFFF;
|
||||||
|
msg->callstack.SetVal( 0 );
|
||||||
|
|
||||||
|
if( m_threadCtx != v.tid )
|
||||||
|
{
|
||||||
|
m_threadCtx = v.tid;
|
||||||
|
m_threadCtxData = nullptr;
|
||||||
|
}
|
||||||
|
InsertMessageData( msg );
|
||||||
}
|
}
|
||||||
InsertMessageData( msg );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for( auto& v : plots )
|
for( auto& v : plots )
|
||||||
@ -512,19 +537,23 @@ Worker::Worker( const char* name, const char* program, const std::vector<ImportE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data.framesBase = m_data.frames.Retrieve( 0, [this] ( uint64_t name ) {
|
// Add a default frame if we didn't have any framesets
|
||||||
auto fd = m_slab.AllocInit<FrameData>();
|
if (frameNames.empty())
|
||||||
fd->name = name;
|
{
|
||||||
fd->continuous = 1;
|
m_data.framesBase = m_data.frames.Retrieve( 0, [this] ( uint64_t name ) {
|
||||||
return fd;
|
auto fd = m_slab.AllocInit<FrameData>();
|
||||||
}, [this] ( uint64_t name ) {
|
fd->name = name;
|
||||||
assert( name == 0 );
|
fd->continuous = 1;
|
||||||
char tmp[6] = "Frame";
|
return fd;
|
||||||
HandleFrameName( name, tmp, 5 );
|
}, [this] ( uint64_t name ) {
|
||||||
} );
|
assert( name == 0 );
|
||||||
|
char tmp[6] = "Frame";
|
||||||
|
HandleFrameName( name, tmp, 5 );
|
||||||
|
} );
|
||||||
|
|
||||||
m_data.framesBase->frames.push_back( FrameEvent{ 0, -1, -1 } );
|
m_data.framesBase->frames.push_back( FrameEvent{ 0, -1, -1 } );
|
||||||
m_data.framesBase->frames.push_back( FrameEvent{ 0, -1, -1 } );
|
m_data.framesBase->frames.push_back( FrameEvent{ 0, -1, -1 } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
|
Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user