コード例 #1
0
ファイル: Program.cs プロジェクト: xiaomi7732/FlameGraphNet
        // Generate a simple tree.
        private static SimpleNode AppendChildren(SimpleNode current, double metricValue)
        {
            metricValue--;
            if (metricValue > 0)
            {
                SimpleNode newChild = new SimpleNode()
                {
                    Content = $"Node {metricValue.ToString("0")}",
                    Metric  = metricValue,
                };

                current.Children.Add(AppendChildren(newChild, metricValue));
            }
            return(current);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: xiaomi7732/FlameGraphNet
        private static void SimpleNodeExample()
        {
            const int  nodeCount = 20;
            SimpleNode root      = new SimpleNode()
            {
                Content = $"Node {nodeCount.ToString("0")}",
                Metric  = nodeCount,
            };

            root = AppendChildren(root, nodeCount);

            FlameGraph newGraph = new FlameGraph(new FlameGraphOptions()
            {
                Title  = "Hello Flame Graph",
                Width  = 800,
                Height = 600,
            });

            string fileName = Path.Combine("Examples", nameof(SimpleNodeExample) + ".svg");

            DeleteFileWhenExists(fileName);
            newGraph.BuildTo(root, fileName);
        }