Ejemplo n.º 1
0
            internal ViewState(SortingBehaviour in_sort, SortingBehaviour in_highlight)
            {
                sort      = in_sort;
                highlight = in_highlight;

                showCalls = showAllocs = showAssemblies = true;
            }
Ejemplo n.º 2
0
        internal SortAndHighlightSelector(SortingBehaviour sort, SortingBehaviour highlight)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            int i, numCounters = Statistics.GetNumberOfCounters();

            sortCounter.Items.Add("in order of execution");
            for (i = 0; i < numCounters; i++)
            {
                sortCounter.Items.Add("by " + Statistics.GetCounterName(i).ToLower());
            }
            sortCounter.SelectedIndex = 1 + sort.CounterId;
            sortOrder.SelectedIndex   = (1 + sort.SortingOrder) / 2;

            for (i = 0; i < numCounters; i++)
            {
                highlightCounter.Items.Add(Statistics.GetCounterName(i).ToLower());
            }
            highlightCounter.SelectedIndex = highlight.CounterId;
            highlightOrder.SelectedIndex   = (1 + highlight.SortingOrder) / 2;
        }
Ejemplo n.º 3
0
        internal (SortingBehaviour s, SortingBehaviour h) GetSortResults()
        {
            var sSortingOrder = sortOrder.SelectedIndex * 2 - 1;
            var sCounterId    = sortCounter.SelectedIndex - 1;

            var s = new SortingBehaviour(sortingOrder: sSortingOrder, counterId: sCounterId);

            var hSortingOrder = highlightOrder.SelectedIndex * 2 - 1;
            var hCounterId    = highlightCounter.SelectedIndex;
            var h             = new SortingBehaviour(sortingOrder: hSortingOrder, counterId: hCounterId);

            return(s, h);
        }
Ejemplo n.º 4
0
        private void InitForm()
        {
            Controls.Clear();
            if (controlCollection != null)
            {
                controlCollection.Controls.Clear();
            }
            InitializeComponent();
            defaultFont = new Font(new FontFamily("Tahoma"), 8);

            DiffTreeListView treeView = new DiffTreeListView(this);

            treeView.Dock = DockStyle.Fill;
            treeView.Font = defaultFont;

            SortingBehaviour sort      = new SortingBehaviour();
            SortingBehaviour highlight = new SortingBehaviour();

            sort.sortingOrder   = highlight.sortingOrder = -1;
            sort.counterId      = -1;
            highlight.counterId = 2;

            /* add columns */
            treeView.AddColumn(new ColumnInformation(-1, "Function name", ColumnInformation.ColumnTypes.Tree), 250);
            foreach (int counter in DiffStatistics.DefaultCounters)
            {
                AddColumn(treeView, counter);
            }

            treeView.ColumnClick += new EventHandler(SortOn);

            treeView.TokenObject = new ViewState(sort, highlight);
            treeView.Root        = Root;


            treeView.Size    = new System.Drawing.Size(332, 108);
            treeView.Visible = true;
            controlCollection.Controls.Add(treeView);
            SetcallTreeView();
            this.Visible = true;
        }
Ejemplo n.º 5
0
        public DiffCallTreeForm([NotNull] TreeNodeBase root, [NotNull] AllocationDiff allocDiff)
        {
            this.Root       = root;
            this._allocDiff = allocDiff;

            Controls.Clear();
            controlCollection?.Controls.Clear();
            InitializeComponent();
            defaultFont = new Font(new FontFamily("Tahoma"), 8);

            var treeView = new DiffTreeListView(this);

            treeView.Dock = DockStyle.Fill;
            treeView.Font = defaultFont;

            var sort      = new SortingBehaviour(sortingOrder: -1, counterId: -1);
            var highlight = new SortingBehaviour(sortingOrder: -1, counterId: 2);

            /* add columns */
            treeView.AddColumn(new ColumnInformation(-1, "Function name", ColumnInformation.ColumnTypes.Tree), 250);
            foreach (int counter in DiffStatistics.DefaultCounters)
            {
                AddColumn(treeView, counter);
            }

            treeView.ColumnClick += new EventHandler(SortOn);

            treeView.ViewState = new ViewState(sort, highlight);
            treeView.Root      = Root;


            treeView.Size    = new System.Drawing.Size(332, 108);
            treeView.Visible = true;
            controlCollection.Controls.Add(treeView);
            SetcallTreeView();
            this.Visible = true;
        }
Ejemplo n.º 6
0
        /* sort nodes at the branch level */
        public ArrayList ProcessNodes(object obj, ArrayList nodes)
        {
            bool      add             = false;
            ArrayList nodesAtOneLevel = new ArrayList();

            foreach (DiffDataNode node in nodes)
            {
                switch (node.nodetype)
                {
                case DiffDataNode.NodeType.Call:
                    add = true;
                    break;

                case DiffDataNode.NodeType.Allocation:
                    add = viewState.showAllocs;
                    break;

                case DiffDataNode.NodeType.AssemblyLoad:
                    add = viewState.showAssemblies;
                    break;
                }

                if (add)
                {
                    nodesAtOneLevel.Add(node);
                }
            }
            if (nodesAtOneLevel.Count == 0)
            {
                return(nodesAtOneLevel);
            }

            /* sort nodes first */
            nodesAtOneLevel.Sort(this);

            /* then choose the nodes to highlight */
            SortingBehaviour ss = viewState.sort;

            /* this is needed to use the default Compare method */
            viewState.sort = viewState.highlight;
            ArrayList    nodesToHighlight = new ArrayList();
            DiffDataNode currentBest      = (DiffDataNode)nodesAtOneLevel[0];

            currentBest.highlighted = false;
            nodesToHighlight.Add(currentBest);
            for (int i = 1; i < nodesAtOneLevel.Count; i++)
            {
                DiffDataNode n = (DiffDataNode)nodesAtOneLevel[i];
                n.highlighted = false;

                int res = Compare(currentBest, n) * viewState.highlight.sortingOrder;
                if (res == 0)
                {
                    nodesToHighlight.Add(n);
                }
                else if (res > 0)
                {
                    currentBest = n;
                    nodesToHighlight.Clear();
                    nodesToHighlight.Add(currentBest);
                }
            }
            viewState.sort = ss;

            foreach (DiffDataNode n in nodesToHighlight)
            {
                n.highlighted = true;
            }

            /* reverse order if required */
            if (viewState.sort.sortingOrder > 0)
            {
                nodesAtOneLevel.Reverse();
            }
            return(nodesAtOneLevel);
        }