Make chrome:tracing importer support both array and object forms of input.

This commit is contained in:
Dmitry Ivanov 2019-12-16 21:41:57 +01:00 committed by Bartosz Taudul
parent 14e096d052
commit a4d12c26c7

View File

@ -56,6 +56,17 @@ int main( int argc, char** argv )
std::vector<tracy::Worker::ImportEventTimeline> timeline; std::vector<tracy::Worker::ImportEventTimeline> timeline;
std::vector<tracy::Worker::ImportEventMessages> messages; std::vector<tracy::Worker::ImportEventMessages> messages;
if( j.is_object() && j.contains( "traceEvents" ) )
{
j = j["traceEvents"];
}
if( !j.is_array() )
{
fprintf( stderr, "Input must be either an array of events or an object containing an array of events under \"traceEvents\" key.\n" );
exit( 1 );
}
for( auto& v : j ) for( auto& v : j )
{ {
const auto type = v["ph"].get<std::string>(); const auto type = v["ph"].get<std::string>();