mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Imported Chrome traces bring over thread names
This commit is contained in:
parent
25a95d99c0
commit
2920f97911
@ -6,6 +6,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "json.hpp"
|
||||
|
||||
@ -56,6 +57,7 @@ int main( int argc, char** argv )
|
||||
std::vector<tracy::Worker::ImportEventTimeline> timeline;
|
||||
std::vector<tracy::Worker::ImportEventMessages> messages;
|
||||
std::vector<tracy::Worker::ImportEventPlots> plots;
|
||||
std::unordered_map<uint64_t, std::string> threadNames;
|
||||
|
||||
if( j.is_object() && j.contains( "traceEvents" ) )
|
||||
{
|
||||
@ -156,6 +158,13 @@ int main( int argc, char** argv )
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type == "M")
|
||||
{
|
||||
if (v.contains("name") && v["name"] == "thread_name" && v.contains("args") && v["args"].is_object() && v["args"].contains("name"))
|
||||
{
|
||||
threadNames[v["tid"].get<uint64_t>()] = v["args"]["name"].get<std::string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::stable_sort( timeline.begin(), timeline.end(), [] ( const auto& l, const auto& r ) { return l.timestamp < r.timestamp; } );
|
||||
@ -189,7 +198,7 @@ int main( int argc, char** argv )
|
||||
while( *program ) program++;
|
||||
program--;
|
||||
while( program > input && ( *program != '/' || *program != '\\' ) ) program--;
|
||||
tracy::Worker worker( program, timeline, messages, plots );
|
||||
tracy::Worker worker( program, timeline, messages, plots, threadNames );
|
||||
|
||||
auto w = std::unique_ptr<tracy::FileWrite>( tracy::FileWrite::Open( output, clev ) );
|
||||
if( !w )
|
||||
|
@ -275,7 +275,7 @@ Worker::Worker( const char* addr, uint16_t port )
|
||||
m_threadNet = std::thread( [this] { SetThreadName( "Tracy Network" ); Network(); } );
|
||||
}
|
||||
|
||||
Worker::Worker( const std::string& program, const std::vector<ImportEventTimeline>& timeline, const std::vector<ImportEventMessages>& messages, const std::vector<ImportEventPlots>& plots )
|
||||
Worker::Worker( const std::string& program, const std::vector<ImportEventTimeline>& timeline, const std::vector<ImportEventMessages>& messages, const std::vector<ImportEventPlots>& plots, const std::unordered_map<uint64_t, std::string>& threadNames )
|
||||
: m_hasData( true )
|
||||
, m_delay( 0 )
|
||||
, m_resolution( 0 )
|
||||
@ -428,9 +428,19 @@ Worker::Worker( const std::string& program, const std::vector<ImportEventTimelin
|
||||
|
||||
for( auto& t : m_threadMap )
|
||||
{
|
||||
char buf[64];
|
||||
sprintf( buf, "%" PRIu64, t.first );
|
||||
AddThreadString( t.first, buf, strlen( buf ) );
|
||||
auto name = threadNames.find(t.first);
|
||||
if (name != threadNames.end())
|
||||
{
|
||||
char buf[128];
|
||||
int len = snprintf(buf, sizeof(buf), "(%" PRIu64 ") %s", t.first, name->second.c_str());
|
||||
AddThreadString(t.first, buf, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf[64];
|
||||
sprintf( buf, "%" PRIu64, t.first );
|
||||
AddThreadString( t.first, buf, strlen( buf ) );
|
||||
}
|
||||
}
|
||||
|
||||
m_data.framesBase = m_data.frames.Retrieve( 0, [this] ( uint64_t name ) {
|
||||
|
@ -394,7 +394,7 @@ public:
|
||||
};
|
||||
|
||||
Worker( const char* addr, uint16_t port );
|
||||
Worker( const std::string& program, const std::vector<ImportEventTimeline>& timeline, const std::vector<ImportEventMessages>& messages, const std::vector<ImportEventPlots>& plots );
|
||||
Worker( const std::string& program, const std::vector<ImportEventTimeline>& timeline, const std::vector<ImportEventMessages>& messages, const std::vector<ImportEventPlots>& plots, const std::unordered_map<uint64_t, std::string>& threadNames );
|
||||
Worker( FileRead& f, EventType::Type eventMask = EventType::All, bool bgTasks = true );
|
||||
~Worker();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user