mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Cache last source location entry.
227 ms -> 138 ms
This commit is contained in:
parent
0c0e4f554f
commit
8b8ff9363d
@ -17,6 +17,9 @@ struct FlameGraphItem
|
||||
|
||||
static void BuildFlameGraph( const Worker& worker, Vector<FlameGraphItem>& data, const Vector<short_ptr<ZoneEvent>>& zones )
|
||||
{
|
||||
FlameGraphItem* it;
|
||||
int16_t last = 0;
|
||||
|
||||
if( zones.is_magic() )
|
||||
{
|
||||
auto& vec = *(Vector<ZoneEvent>*)&zones;
|
||||
@ -25,7 +28,18 @@ static void BuildFlameGraph( const Worker& worker, Vector<FlameGraphItem>& data,
|
||||
if( !v.IsEndValid() ) break;
|
||||
const auto srcloc = v.SrcLoc();
|
||||
const auto duration = v.End() - v.Start();
|
||||
auto it = std::find_if( data.begin(), data.end(), [srcloc]( const auto& v ) { return v.srcloc == srcloc; } );
|
||||
if( srcloc == last )
|
||||
{
|
||||
it->time += duration;
|
||||
if( v.HasChildren() )
|
||||
{
|
||||
auto& children = worker.GetZoneChildren( v.Child() );
|
||||
BuildFlameGraph( worker, it->children, children );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
it = std::find_if( data.begin(), data.end(), [srcloc]( const auto& v ) { return v.srcloc == srcloc; } );
|
||||
if( it == data.end() )
|
||||
{
|
||||
data.push_back( FlameGraphItem { srcloc, duration } );
|
||||
@ -34,6 +48,7 @@ static void BuildFlameGraph( const Worker& worker, Vector<FlameGraphItem>& data,
|
||||
auto& children = worker.GetZoneChildren( v.Child() );
|
||||
BuildFlameGraph( worker, data.back().children, children );
|
||||
}
|
||||
it = &data.back();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -44,6 +59,8 @@ static void BuildFlameGraph( const Worker& worker, Vector<FlameGraphItem>& data,
|
||||
BuildFlameGraph( worker, it->children, children );
|
||||
}
|
||||
}
|
||||
last = srcloc;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -53,7 +70,18 @@ static void BuildFlameGraph( const Worker& worker, Vector<FlameGraphItem>& data,
|
||||
if( !v->IsEndValid() ) break;
|
||||
const auto srcloc = v->SrcLoc();
|
||||
const auto duration = v->End() - v->Start();
|
||||
auto it = std::find_if( data.begin(), data.end(), [srcloc]( const auto& v ) { return v.srcloc == srcloc; } );
|
||||
if( srcloc == last )
|
||||
{
|
||||
it->time += duration;
|
||||
if( v->HasChildren() )
|
||||
{
|
||||
auto& children = worker.GetZoneChildren( v->Child() );
|
||||
BuildFlameGraph( worker, it->children, children );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
it = std::find_if( data.begin(), data.end(), [srcloc]( const auto& v ) { return v.srcloc == srcloc; } );
|
||||
if( it == data.end() )
|
||||
{
|
||||
data.push_back( FlameGraphItem { srcloc, duration } );
|
||||
@ -62,6 +90,7 @@ static void BuildFlameGraph( const Worker& worker, Vector<FlameGraphItem>& data,
|
||||
auto& children = worker.GetZoneChildren( v->Child() );
|
||||
BuildFlameGraph( worker, data.back().children, children );
|
||||
}
|
||||
it = &data.back();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -72,6 +101,8 @@ static void BuildFlameGraph( const Worker& worker, Vector<FlameGraphItem>& data,
|
||||
BuildFlameGraph( worker, it->children, children );
|
||||
}
|
||||
}
|
||||
last = srcloc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user