mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 14:44:34 +00:00
remove dead code
This commit is contained in:
parent
90b2c986ee
commit
a275f1a2e0
@ -551,142 +551,6 @@ int main(int argc, char **argv) {
|
||||
printf("read %d records\n", n_records);
|
||||
fflush(stdout);
|
||||
|
||||
/*
|
||||
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 )
|
||||
{
|
||||
const auto type = v["ph"].get<std::string>();
|
||||
|
||||
std::string zoneText = "";
|
||||
if( v.contains( "args" ) )
|
||||
{
|
||||
for( auto& kv : v["args"].items() )
|
||||
{
|
||||
const auto val = kv.value();
|
||||
const std::string s = val.is_string() ? val.get<std::string>()
|
||||
: val.dump(); zoneText += kv.key() + ": " + s + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
std::string locFile;
|
||||
uint32_t locLine = 0;
|
||||
if( v.contains( "loc" ) )
|
||||
{
|
||||
auto loc = v["loc"].get<std::string>();
|
||||
const auto lpos = loc.find_last_of( ':' );
|
||||
if( lpos == std::string::npos )
|
||||
{
|
||||
std::swap( loc, locFile );
|
||||
}
|
||||
else
|
||||
{
|
||||
locFile = loc.substr( 0, lpos );
|
||||
locLine = atoi( loc.c_str() + lpos + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
if( type == "b" || type == "B" )
|
||||
{
|
||||
timeline.emplace_back( tracy::Worker::ImportEventTimeline {
|
||||
getPseudoTid(v),
|
||||
uint64_t( v["ts"].get<double>() * 1000. ),
|
||||
v["name"].get<std::string>(),
|
||||
std::move(zoneText),
|
||||
false,
|
||||
std::move(locFile),
|
||||
locLine
|
||||
} );
|
||||
}
|
||||
else if( type == "e" || type == "E" )
|
||||
{
|
||||
timeline.emplace_back( tracy::Worker::ImportEventTimeline {
|
||||
getPseudoTid(v),
|
||||
uint64_t( v["ts"].get<double>() * 1000. ),
|
||||
"",
|
||||
std::move(zoneText),
|
||||
true
|
||||
} );
|
||||
}
|
||||
else if( type == "X" )
|
||||
{
|
||||
const auto tid = getPseudoTid(v);
|
||||
const auto ts0 = uint64_t( v["ts"].get<double>() * 1000. );
|
||||
const auto ts1 = ts0 + uint64_t( v["dur"].get<double>() * 1000. );
|
||||
const auto name = v["name"].get<std::string>();
|
||||
timeline.emplace_back( tracy::Worker::ImportEventTimeline { tid,
|
||||
ts0, name, std::move(zoneText), false, std::move(locFile), locLine } );
|
||||
timeline.emplace_back( tracy::Worker::ImportEventTimeline { tid,
|
||||
ts1, "", "", true } );
|
||||
}
|
||||
else if( type == "i" || type == "I" )
|
||||
{
|
||||
messages.emplace_back( tracy::Worker::ImportEventMessages {
|
||||
getPseudoTid(v),
|
||||
uint64_t( v["ts"].get<double>() * 1000. ),
|
||||
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 }
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type == "M")
|
||||
{
|
||||
if (v.contains("name") && v["name"] == "thread_name" &&
|
||||
v.contains("args") && v["args"].is_object() && v["args"].contains("name"))
|
||||
{
|
||||
const auto tid = getPseudoTid(v);
|
||||
threadNames[tid] = v["args"]["name"].get<std::string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
std::stable_sort(
|
||||
timeline.begin(), timeline.end(),
|
||||
[](const auto &l, const auto &r) { return l.timestamp < r.timestamp; });
|
||||
|
Loading…
Reference in New Issue
Block a user