import-chrome: import zone metadata from "args" key

This commit is contained in:
Dmitry Ivanov 2020-05-12 20:36:11 +02:00
parent 8e11cd5ebb
commit bcbf8edd8a
2 changed files with 14 additions and 3 deletions

1
NEWS
View File

@ -9,6 +9,7 @@ a mistake.
v0.7 (xxxx-xx-xx) v0.7 (xxxx-xx-xx)
----------------- -----------------
- chrome:tracing importer now imports zone metadata from "args" key.
- Added display of statistical mode to find zone menu. - Added display of statistical mode to find zone menu.
- Automatic stack sampling is now available on windows. - Automatic stack sampling is now available on windows.
- Properly handle tracing on long-running systems. - Properly handle tracing on long-running systems.

View File

@ -70,13 +70,23 @@ int main( int argc, char** argv )
for( auto& v : j ) for( auto& v : j )
{ {
const auto type = v["ph"].get<std::string>(); const auto type = v["ph"].get<std::string>();
std::string zoneText = "";
if ( v.contains( "args" ) )
{
for ( auto& kv : v["args"].items() )
{
zoneText += kv.key() + ": " + kv.value().dump() + "\n";
}
}
if( type == "B" ) if( type == "B" )
{ {
timeline.emplace_back( tracy::Worker::ImportEventTimeline { timeline.emplace_back( tracy::Worker::ImportEventTimeline {
v["tid"].get<uint64_t>(), v["tid"].get<uint64_t>(),
uint64_t( v["ts"].get<double>() * 1000. ), uint64_t( v["ts"].get<double>() * 1000. ),
v["name"].get<std::string>(), v["name"].get<std::string>(),
"", std::move(zoneText),
false false
} ); } );
} }
@ -86,7 +96,7 @@ int main( int argc, char** argv )
v["tid"].get<uint64_t>(), v["tid"].get<uint64_t>(),
uint64_t( v["ts"].get<double>() * 1000. ), uint64_t( v["ts"].get<double>() * 1000. ),
"", "",
"", std::move(zoneText),
true true
} ); } );
} }
@ -96,7 +106,7 @@ int main( int argc, char** argv )
const auto ts0 = uint64_t( v["ts"].get<double>() * 1000. ); const auto ts0 = uint64_t( v["ts"].get<double>() * 1000. );
const auto ts1 = v["dur"].is_object() ? ts0 + uint64_t( v["dur"].get<double>() * 1000. ) : ts0; const auto ts1 = v["dur"].is_object() ? ts0 + uint64_t( v["dur"].get<double>() * 1000. ) : ts0;
const auto name = v["name"].get<std::string>(); const auto name = v["name"].get<std::string>();
timeline.emplace_back( tracy::Worker::ImportEventTimeline { tid, ts0, name, "", false } ); timeline.emplace_back( tracy::Worker::ImportEventTimeline { tid, ts0, name, std::move(zoneText), false } );
timeline.emplace_back( tracy::Worker::ImportEventTimeline { tid, ts1, "", "", true } ); timeline.emplace_back( tracy::Worker::ImportEventTimeline { tid, ts1, "", "", true } );
} }
else if( type == "i" || type == "I" ) else if( type == "i" || type == "I" )