1 //===-- xray-graph-diff.h - XRay Graph Diff Renderer ------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // Generate a DOT file to represent the difference between the function call
10 // graph of two differnent traces.
12 //===----------------------------------------------------------------------===//
14 #ifndef XRAY_GRAPH_DIFF_H
15 #define XRAY_GRAPH_DIFF_H
17 #include "xray-graph.h"
18 #include "llvm/ADT/StringMap.h"
19 #include "llvm/XRay/Graph.h"
24 // This class creates a graph representing the difference between two
25 // xray-graphs And allows you to print it to a dot file, with optional color
27 class GraphDiffRenderer
{
28 static const int N
= 2;
31 using StatType
= GraphRenderer::StatType
;
32 using TimeStat
= GraphRenderer::TimeStat
;
34 using GREdgeValueType
= GraphRenderer::GraphT::EdgeValueType
;
35 using GRVertexValueType
= GraphRenderer::GraphT::VertexValueType
;
37 struct EdgeAttribute
{
38 std::array
<const GREdgeValueType
*, N
> CorrEdgePtr
= {};
41 struct VertexAttribute
{
42 std::array
<const GRVertexValueType
*, N
> CorrVertexPtr
= {};
45 using GraphT
= Graph
<VertexAttribute
, EdgeAttribute
, StringRef
>;
48 std::array
<std::reference_wrapper
<const GraphRenderer::GraphT
>, N
> G
;
51 template <typename
... Ts
> Factory(Ts
&... Args
) : G
{{Args
...}} {}
53 Expected
<GraphDiffRenderer
> getGraphDiffRenderer();
59 GraphDiffRenderer() = default;
62 void exportGraphAsDOT(raw_ostream
&OS
, StatType EdgeLabel
= StatType::NONE
,
63 StatType EdgeColor
= StatType::NONE
,
64 StatType VertexLabel
= StatType::NONE
,
65 StatType VertexColor
= StatType::NONE
,
68 const GraphT
&getGraph() { return G
; }