Merge pull request #58 from ethercrow/import-chrome-metrics

Import chrome metrics
This commit is contained in:
Bartosz Taudul 2020-06-21 14:39:52 +02:00 committed by GitHub
commit 0fff0ac754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 2 deletions

View File

@ -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 );

View File

@ -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 )