mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-23 06:44:35 +00:00
Merge pull request #58 from ethercrow/import-chrome-metrics
Import chrome metrics
This commit is contained in:
commit
0fff0ac754
@ -118,6 +118,44 @@ int main( int argc, char** argv )
|
||||
v["name"].get<std::string>()
|
||||
} );
|
||||
}
|
||||
else if( type == "C" )
|
||||
{
|
||||
auto timestamp = int64_t( v["ts"].get<double>() * 1000 );
|
||||
for( auto& kv : v["args"].items() )
|
||||
{
|
||||
bool plotFound = false;
|
||||
auto& metricName = kv.key();
|
||||
auto dataPoint = std::make_pair( timestamp, kv.value().get<double>() );
|
||||
|
||||
// The input file is assumed to have only very few metrics,
|
||||
// so iterating through plots is not a problem.
|
||||
for( auto& plot : plots )
|
||||
{
|
||||
if( plot.name == metricName )
|
||||
{
|
||||
plot.data.emplace_back( dataPoint );
|
||||
plotFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !plotFound )
|
||||
{
|
||||
auto formatting = tracy::PlotValueFormatting::Number;
|
||||
|
||||
// NOTE: With C++20 one could say metricName.ends_with( "_bytes" ) instead of rfind
|
||||
auto metricNameLen = metricName.size();
|
||||
if ( metricNameLen >= 6 && metricName.rfind( "_bytes" ) == metricNameLen - 6 ) {
|
||||
formatting = tracy::PlotValueFormatting::Memory;
|
||||
}
|
||||
|
||||
plots.emplace_back( tracy::Worker::ImportEventPlots {
|
||||
std::move( metricName ),
|
||||
formatting,
|
||||
{ dataPoint }
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::stable_sort( timeline.begin(), timeline.end(), [] ( const auto& l, const auto& r ) { return l.timestamp < r.timestamp; } );
|
||||
@ -133,8 +171,16 @@ int main( int argc, char** argv )
|
||||
{
|
||||
if( mts > messages[0].timestamp ) mts = messages[0].timestamp;
|
||||
}
|
||||
for( auto& plot : plots )
|
||||
{
|
||||
if( mts > plot.data[0].first ) mts = plot.data[0].first;
|
||||
}
|
||||
for( auto& v : timeline ) v.timestamp -= mts;
|
||||
for( auto& v : messages ) v.timestamp -= mts;
|
||||
for( auto& plot : plots )
|
||||
{
|
||||
for( auto& v : plot.data ) v.first -= mts;
|
||||
}
|
||||
|
||||
printf( "\33[2KProcessing...\r" );
|
||||
fflush( stdout );
|
||||
|
@ -400,8 +400,8 @@ Worker::Worker( const std::string& program, const std::vector<ImportEventTimelin
|
||||
plot->type = PlotType::User;
|
||||
plot->format = v.format;
|
||||
|
||||
double min = v.data.begin()->first;
|
||||
double max = v.data.begin()->first;
|
||||
double min = v.data.begin()->second;
|
||||
double max = v.data.begin()->second;
|
||||
plot->data.reserve_exact( v.data.size(), m_slab );
|
||||
size_t idx = 0;
|
||||
for( auto& p : v.data )
|
||||
|
Loading…
Reference in New Issue
Block a user