diff --git a/import-chrome/src/import-chrome.cpp b/import-chrome/src/import-chrome.cpp index a0708143..4fb353cc 100644 --- a/import-chrome/src/import-chrome.cpp +++ b/import-chrome/src/import-chrome.cpp @@ -118,6 +118,44 @@ int main( int argc, char** argv ) v["name"].get() } ); } + else if( type == "C" ) + { + auto timestamp = int64_t( v["ts"].get() * 1000 ); + for( auto& kv : v["args"].items() ) + { + bool plotFound = false; + auto& metricName = kv.key(); + auto dataPoint = std::make_pair( timestamp, kv.value().get() ); + + // 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; } ); @@ -135,6 +173,9 @@ int main( int argc, char** argv ) } 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 ); diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 61690dcd..e8355ddb 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -400,8 +400,8 @@ Worker::Worker( const std::string& program, const std::vectortype = 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 )