Use precalculated start times.

This commit is contained in:
Bartosz Taudul 2024-10-27 12:00:34 +01:00
parent 9d2f874b02
commit ceeea7712d
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 8 additions and 9 deletions

View File

@ -277,8 +277,8 @@ private:
void DrawWaitStacks();
void DrawFlameGraph();
void DrawFlameGraphHeader( uint64_t timespan );
void DrawFlameGraphLevel( const std::vector<FlameGraphItem>& data, FlameGraphContext& ctx, uint64_t ts, int depth, bool samples );
void DrawFlameGraphItem( const FlameGraphItem& item, FlameGraphContext& ctx, uint64_t ts, int depth, bool samples );
void DrawFlameGraphLevel( const std::vector<FlameGraphItem>& data, FlameGraphContext& ctx, int depth, bool samples );
void DrawFlameGraphItem( const FlameGraphItem& item, FlameGraphContext& ctx, int depth, bool samples );
void BuildFlameGraph( const Worker& worker, std::vector<FlameGraphItem>& data, const Vector<short_ptr<ZoneEvent>>& zones );
void BuildFlameGraph( const Worker& worker, std::vector<FlameGraphItem>& data, const Vector<short_ptr<ZoneEvent>>& zones, const ContextSwitch* ctx );
void BuildFlameGraph( const Worker& worker, std::vector<FlameGraphItem>& data, const Vector<SampleData>& samples );

View File

@ -260,18 +260,17 @@ struct FlameGraphContext
double nspx;
};
void View::DrawFlameGraphLevel( const std::vector<FlameGraphItem>& data, FlameGraphContext& ctx, uint64_t ts, int depth, bool samples )
void View::DrawFlameGraphLevel( const std::vector<FlameGraphItem>& data, FlameGraphContext& ctx, int depth, bool samples )
{
for( auto& v : data )
{
DrawFlameGraphItem( v, ctx, ts, depth, samples );
ts += v.time;
DrawFlameGraphItem( v, ctx, depth, samples );
}
}
void View::DrawFlameGraphItem( const FlameGraphItem& item, FlameGraphContext& ctx, uint64_t ts, int depth, bool samples )
void View::DrawFlameGraphItem( const FlameGraphItem& item, FlameGraphContext& ctx, int depth, bool samples )
{
const auto x0 = ctx.dpos.x + ts * ctx.pxns;
const auto x0 = ctx.dpos.x + item.begin * ctx.pxns;
const auto x1 = x0 + item.time * ctx.pxns;
const auto y0 = ctx.dpos.y + depth * ctx.ostep;
const auto y1 = y0 + ctx.ty;
@ -457,7 +456,7 @@ void View::DrawFlameGraphItem( const FlameGraphItem& item, FlameGraphContext& ct
}
}
DrawFlameGraphLevel( item.children, ctx, ts, depth+1, samples );
DrawFlameGraphLevel( item.children, ctx, depth+1, samples );
}
void View::DrawFlameGraphHeader( uint64_t timespan )
@ -740,7 +739,7 @@ void View::DrawFlameGraph()
ctx.nspx = 1.0 / ctx.pxns;
ImGui::ItemSize( region );
DrawFlameGraphLevel( m_flameGraphData, ctx, 0, 0, m_flameMode == 1 );
DrawFlameGraphLevel( m_flameGraphData, ctx, 0, m_flameMode == 1 );
}
ImGui::EndChild();