Esempio n. 1
0
        /* implements IComparer that compares the nodes according to the current sorting order */
        public int Compare(object x, object y)
        {
            DiffDataNode a = (DiffDataNode)x;
            DiffDataNode b = (DiffDataNode)y;

            if (viewState.sort.counterId == -1)
            {
                return(a.nodeId.CompareTo(b.nodeId));
            }

            IComparable aa = (IComparable)GetInfo(null, a, viewState.sort.counterId);
            IComparable bb = (IComparable)GetInfo(null, b, viewState.sort.counterId);

            try
            {
                return(aa.CompareTo(bb));
            }
            catch
            {
                /* if string ("" is used instead of 0) is being compared against a number */
                bool aazero = (aa.ToString() == "");
                bool bbzero = (bb.ToString() == "");
                return(aazero && bbzero ? 0 : aazero ? -1 : 1);
            }
        }
Esempio n. 2
0
        public Color GetColor(object obj, TreeNodeBase root, bool positive)
        {
            DiffDataNode node = (DiffDataNode)root;
            int          idx  = (int)node.nodetype + (positive ? 0 : 3);

            return(new Color[]
            {
                Color.Black,
                Color.Green,
                Color.BlueViolet,
                Color.White,
                Color.Yellow,
                Color.Beige
            }[idx]);
        }
Esempio n. 3
0
        /* returns font used to display the item (part of the ITreeOwner interface) */
        public Font GetFont(object obj, TreeNodeBase in_node)
        {
            DiffDataNode node = (DiffDataNode)in_node;
            FontStyle    fs   = FontStyle.Regular;

            if (node.data.firstTimeBroughtIn)
            {
                fs |= FontStyle.Italic;
            }
            if (node.highlighted)
            {
                fs |= FontStyle.Bold;
            }
            return(fs == FontStyle.Regular ? defaultFont : new Font(defaultFont, fs));
        }
Esempio n. 4
0
        private void GetTreeContent(StringBuilder sb, DiffDataNode root)
        {
            string prefx = "-";

            for (int i = 0; i < root.depth; i++)
            {
                prefx += '-';
            }
            sb.AppendFormat("{0}{1},{2},{3},{4},{5},{6},{7}\r\n", prefx, root.name, root.prevIncl, root.currIncl.ToString(), root.diffIncl.ToString(), root.prevCalls.ToString(), root.currCalls.ToString(), root.diffCalls.ToString());

            if (root.IsExpanded)
            {
                for (int i = 0; i < root.allkids.Count; i++)
                {
                    GetTreeContent(sb, root.allkids[i] as DiffDataNode);
                }
            }
        }
Esempio n. 5
0
        /* returns data about the item for a given counter.
         * object's ToString() is used to display that data */
        private object GetInfo(object obj, TreeNodeBase node, int counterId)
        {
            long         number = 0;
            DiffDataNode root   = (DiffDataNode)node;

            if (counterId < 0)
            {
                return(root.name);
            }
            else
            {
                number = root.data.GetCounterValue(counterId);
            }
            /* use empty string to denote `0` */
            if (number == 0)
            {
                return("");
            }
            return(number);
        }
		private void GetTreeContent(StringBuilder sb, DiffDataNode root)
		{
			string prefx = "-";
			
			for(int i = 0; i < root.depth; i++)
			{
				prefx += '-';
			}
			sb.AppendFormat("{0}{1},{2},{3},{4},{5},{6},{7}\r\n", prefx, root.name, root.prevIncl, root.currIncl.ToString(), root.diffIncl.ToString(), root.prevCalls.ToString(), root.currCalls.ToString(), root.diffCalls.ToString());
			
			if(root.IsExpanded)
			{
				for(int i = 0; i < root.allkids.Count; i++)
				{
					GetTreeContent(sb, root.allkids[i] as DiffDataNode);
				}
			}

		}
Esempio n. 7
0
		private void ViewCallTrace(string name, int prevIncl, int currIncl, int diffIncl)
		{
			if(name == "<root>")
			{
				diffcallTreeForm = new DiffCallTreeForm(_allocDiff.Root, _allocDiff);
				return;
			}
						
			DiffDataNode root = new DiffDataNode(name);
			DiffDataNode tmproot = new DiffDataNode(name);
			tmproot.mapname = name;
			root.mapname = name;
			root.prevIncl = prevIncl;
			root.currIncl = currIncl;
			root.diffIncl = diffIncl;

			root.currFunId = -1;
			root.prevFunId = -1;
			string diffkey = null;
			string filter = null;
			DataRow[] rRoot = null;
			
			if(_allocDiff._currcallTrace.LogResult.allocatedHistogram.readNewLog.funcSignatureIdHash.ContainsKey(name))
			{
				root.currFunId = _allocDiff._currcallTrace.LogResult.allocatedHistogram.readNewLog.funcSignatureIdHash[name];
			}
			if(_allocDiff._prevcallTrace.LogResult.allocatedHistogram.readNewLog.funcSignatureIdHash.ContainsKey(name))
			{
				root.prevFunId = _allocDiff._prevcallTrace.LogResult.allocatedHistogram.readNewLog.funcSignatureIdHash[name];
			}
			if(!(root.prevFunId == -1 && root.currFunId == -1))
			{
				filter = "(prevIncl = " + prevIncl + ") and (currIncl = " + currIncl + ") and (prevFunId = " + root.prevFunId + ") and (currFunId = " + root.currFunId + ")";
				rRoot = _allocDiff.summaryTracetbl.Select(filter, "depth asc");
				
				if(rRoot.Length ==0 )
				{
					filter = "(prevFunId = " + root.prevFunId + ") or (currFunId = " + root.currFunId + ")";
					rRoot = _allocDiff.summaryTracetbl.Select(filter, "depth asc");
					
					if(rRoot.Length == 0)
					{
						filter = "(currFunId = " + root.currFunId + ") and (prevFunId = -1)";
						rRoot = _allocDiff.summaryTracetbl.Select(filter, "depth asc");
						
						if(rRoot.Length == 0)
						{
							filter = "(prevFunId = " + root.prevFunId + ") and (currFunId = -1)";
							rRoot = _allocDiff.summaryTracetbl.Select(filter, "depth asc");
							if(rRoot.Length == 0)
							{
								filter = null;
							}
						}
					}
				}
			}
		
			if(filter != null)
			{
				if(rRoot.Length == 1)
				{
					tmproot = _allocDiff.Row2Node(rRoot[0]);
					diffkey = tmproot.mapname + tmproot.prevIncl + tmproot.currIncl + tmproot.diffIncl + tmproot.prevFunId + tmproot.currFunId;
					root = _allocDiff.diffCallTreeNodes[diffkey] as DiffDataNode;
				}
				else if(rRoot.Length > 1 )
				{
					long sum = 0;
					string depth = null;
					long diffincl = 0;
					Hashtable depLst = new Hashtable();
					Hashtable depSum = new Hashtable();
					for(int i = 0; i < rRoot.Length; i++)
					{
						depth = rRoot[i][idx_depth].ToString();
						diffincl= long.Parse(rRoot[i][idx_diffIncl].ToString());
						sum += diffincl;
						if(depLst.Contains(depth))
						{
							ArrayList alst = (ArrayList)depLst[depth];
							alst.Add(rRoot[i]);
							depLst[depth] = alst;
							diffincl += (long)depSum[depth];
						}
						else
						{
							ArrayList alst = new ArrayList();
							alst.Add(rRoot[i]);							
							depLst.Add(depth, alst);
							depSum.Add(depth, diffincl);
						}
						if(diffincl == root.diffIncl)
							break;
					}
					
					if(sum != root.diffIncl && diffincl == root.diffIncl )
					{
						if(depLst.ContainsKey(depth))
						{
							ArrayList lst = (ArrayList)depLst[depth];
							for(int i = 0; i < lst.Count; i++)
							{
								DataRow r = (DataRow)lst[i];
								tmproot = _allocDiff.Row2Node(r);
								diffkey = tmproot.mapname + tmproot.prevIncl + tmproot.currIncl + tmproot.diffIncl + tmproot.prevFunId + tmproot.currFunId;
								DiffDataNode subRoot =  _allocDiff.diffCallTreeNodes[diffkey] as DiffDataNode;
								root.allkids.Add(subRoot);
							}
						}
					}
					else
					{

						for(int i = 0; i < rRoot.Length; i++)
						{
							tmproot = _allocDiff.Row2Node(rRoot[i]);
							if(tmproot.depth > 0)
							{
								diffkey = tmproot.mapname + tmproot.prevIncl + tmproot.currIncl + tmproot.diffIncl + tmproot.prevFunId + tmproot.currFunId;
								DiffDataNode subRoot =  _allocDiff.diffCallTreeNodes[diffkey] as DiffDataNode;
								root.allkids.Add(subRoot);
							}
						}
					}
					root.HasKids = true;
					root.depth = 0;

				}
				diffcallTreeForm.Close();
				diffcallTreeForm = new DiffCallTreeForm(root, _allocDiff);
			}
			
		}
		private void BuildDiffTraceTable(DiffDataNode parent, TreeNode currRoot, TreeNode prevRoot)
		{
			ArrayList currKids = new ArrayList();
			ArrayList prevKids = new ArrayList();
			ArrayList currDKids = new ArrayList();
			ArrayList prevDKids = new ArrayList();

			//get kids
			if(currRoot != null)
			{
				currKids = _currcallTrace.FetchKids(null, currRoot);
				if(currKids.Count >0)
				{
					currDKids = TransCurrTree(currKids);
				}
			}
			if(prevRoot != null)
			{
				prevKids = _prevcallTrace.FetchKids(null, prevRoot);
				if(prevKids.Count > 0)
				{
					prevDKids = TransPrevTree(prevKids);
				}
			}
          
			// get diff node
			ArrayList diffKids = GetDiffKids(parent, currDKids, prevDKids);

			// recursive for each diff node
			for(int i = 0; i < diffKids.Count; i++)
			{
				BuildDiffTraceTable(diffKids[i] as DiffDataNode, ((DiffDataNode)diffKids[i]).currTreenode as TreeNode, ((DiffDataNode)diffKids[i]).prevTreenode as TreeNode);
				
			}
			

		}
Esempio n. 9
0
        internal DiffStatistics(DiffDataNode node)
        {
            this.node = node;

            firstTimeBroughtIn = false;
        }
Esempio n. 10
0
		private void BuildSummaryTable(DiffDataNode parent, int parentId, string filter)
		{
			depth++;
			parent.depth = depth;
			parent.allkids.Clear();
			parent.HasKids = false;
			Hashtable kidSum = new Hashtable();
			string name = null;
			
			DataRow[] kidsRows = diffTracetbl.Select(filter);
			for(int i = 0; i < kidsRows.Length; i++)
			{
				DiffDataNode sumNode = Row2Node(kidsRows[i]);
				name = sumNode.mapname;
				if(kidSum.ContainsKey(name))
				{
					DiffDataNode updateNode = kidSum[name] as DiffDataNode;
					updateNode.prevIncl += sumNode.prevIncl;
					updateNode.currIncl += sumNode.currIncl;
					updateNode.diffIncl = updateNode.currIncl - updateNode.prevIncl;
					if(sumNode.prevIncl != 0)
					{
						updateNode.prevCalls++;
					}
					if(sumNode.currIncl != 0)
					{
						updateNode.currCalls++;
					}
					updateNode.diffCalls = updateNode.currCalls - updateNode.prevCalls;
					updateNode.allkids.Add(sumNode.nodeId);
					updateNode.HasKids = true;
					
				}
				else
				{
					if(sumNode.prevIncl != 0)
					{
						sumNode.prevCalls = 1;
					}
					if(sumNode.currIncl != 0)
					{
						sumNode.currCalls = 1;
					}
					sumNode.parentId = parentId;
					sumNode.allkids.Add(sumNode.nodeId);
					sumNode.diffIncl = sumNode.currIncl - sumNode.prevIncl;
					sumNode.diffCalls = sumNode.currCalls - sumNode.prevCalls;
					kidSum.Add(name, sumNode);
					sumNode.HasKids = false;
					sumNode.depth = depth;
					sumNode.nodeId = sumnodeidx;
					sumnodeidx++;
				}
				
			}
			if(kidSum.Count > 0)
			{
				if(parent.nodetype == DiffDataNode.NodeType.Call)
				{
					parent.HasKids = true;
				}
				string diffkey = parent.mapname + parent.prevIncl + parent.currIncl + parent.diffIncl + parent.prevFunId + parent.currFunId;
				if(!diffCallTreeNodes.ContainsKey(diffkey))
				{
					diffCallTreeNodes.Add(diffkey, parent);
				}
				
			}
						

			foreach(string key in kidSum.Keys)
			{
				DiffDataNode sumNode = kidSum[key] as DiffDataNode;
				if(! (sumNode.diffIncl == 0))
				{
					parent.allkids.Add(sumNode);
                    AddDiffTraceTableRow(summaryTracetbl, sumNode);
				}
				string kidFilter = getFilter(sumNode.allkids);
				BuildSummaryTable(sumNode, sumNode.nodeId,kidFilter);
			}
			
			depth--;
			
		}
Esempio n. 11
0
		internal void GetAllKids(DiffDataNode root, string filter)
		{
			DataRow[] rKids = summaryTracetbl.Select(filter, "name asc");
			if(rKids.Length > 0)
			{
				root.HasKids = true;
				root.depth = 0;
			}
			for(int i = 0; i < rKids.Length; i++)
			{
				DiffDataNode kidNode = Row2Node(rKids[i]);
				root.allkids.Add(kidNode);
				
			}
		}
Esempio n. 12
0
		internal void RefreshCallTreeNodes(DiffDataNode node)
		{
			node.IsExpanded = false;
			for(int i = 0; i < node.allkids.Count; i++)
			{
				RefreshCallTreeNodes(node.allkids[i] as DiffDataNode);
			}

		}
Esempio n. 13
0
		private int FirstMatchIndex(ArrayList nodelst, DiffDataNode node)
		{
			
			int idx = -1;
			long savedalloc = long.MaxValue;
			long alloc = 0;

			for(int i = 0; i < nodelst.Count; i++)
			{
				if( ((DiffDataNode)nodelst[i]).name.Equals(node.name) && 
					!((DiffDataNode)nodelst[i]).marked )
				{
					alloc = Math.Abs(node.currIncl - ((DiffDataNode)nodelst[i]).prevIncl);
					if(alloc < savedalloc)
					{
						idx = i;
						savedalloc = alloc;
						continue;
					}
				}
			}
			
			return idx;
		}
Esempio n. 14
0
		private int PrevExactMatchIndex(ArrayList nodelst, DiffDataNode node)
		{
			for(int i = 0; i < nodelst.Count; i++)
			{
				if( ((DiffDataNode)nodelst[i]).name.Equals(node.name) && 
					!((DiffDataNode)nodelst[i]).marked &&
					(node.prevIncl - ((DiffDataNode)nodelst[i]).currIncl) == 0)
				{
					return i;
				}
			}
			return -1;
		}
Esempio n. 15
0
		private ArrayList GetDiffKids(DiffDataNode parent, ArrayList currKids, ArrayList prevKids)
		{
			ArrayList curr = new ArrayList();
			Hashtable curr_inclOfNode = new Hashtable();
			ArrayList prev = new ArrayList();
			Hashtable prev_inclOfNode = new Hashtable();

			ArrayList diffnodes = new ArrayList();
			for(int i = 0; i < currKids.Count; i++)
			{
				if( !((DiffDataNode)currKids[i]).marked)
				{
					DiffDataNode node = new DiffDataNode( ((DiffDataNode)currKids[i]).name);
					int idx = CurrExactMatchIndex(prevKids, currKids[i] as DiffDataNode);
					if(idx >=0)
					{
						node.currFunId = ((DiffDataNode)currKids[i]).currFunId;
						node.prevFunId = ((DiffDataNode)prevKids[idx]).prevFunId;
						node.mapname = ((DiffDataNode)currKids[i]).mapname;
						node.currIncl = ((DiffDataNode)currKids[i]).currIncl;
						node.prevIncl = ((DiffDataNode)prevKids[idx]).prevIncl;
						node.diffIncl = node.currIncl - node.prevIncl;
						node.currCalls = ((DiffDataNode)currKids[i]).currCalls;
						node.prevCalls = ((DiffDataNode)prevKids[idx]).prevCalls;
						node.diffCalls = node.currCalls - node.prevCalls;
						
						node.nodeId = nodeidx;
						node.parentId = parent.nodeId;
						node.parentname = parent.name;
						node.currTreenode = ((DiffDataNode)currKids[i]).currTreenode;
						node.prevTreenode = ((DiffDataNode)prevKids[idx]).prevTreenode;
						node.nodetype = ((DiffDataNode)currKids[i]).nodetype;

						((DiffDataNode)currKids[i]).marked = true;
						((DiffDataNode)prevKids[idx]).marked = true;
						if(node.diffIncl != 0)
						{
							diffnodes.Add(node);
							AddDiffTraceTableRow(diffTracetbl, node);
							nodeidx++;
						
						}
					}
					else
					{
						long incl = ((DiffDataNode)currKids[i]).currIncl;
						curr_inclOfNode[currKids[i]] = incl; 
						curr.Add(currKids[i]);
					}
				}
			}

			for(int i = 0; i < prevKids.Count; i++)
			{
				if( !((DiffDataNode)prevKids[i]).marked)
				{
					DiffDataNode node = new DiffDataNode( ((DiffDataNode)prevKids[i]).name);
					int idx = PrevExactMatchIndex(currKids, prevKids[i] as DiffDataNode);
					if(idx >=0)
					{
						node.currFunId = ((DiffDataNode)currKids[idx]).currFunId;
						node.prevFunId = ((DiffDataNode)prevKids[i]).prevFunId;
						node.mapname = ((DiffDataNode)currKids[idx]).mapname;
						node.currIncl = ((DiffDataNode)currKids[idx]).currIncl;
						node.prevIncl = ((DiffDataNode)prevKids[i]).prevIncl;
						node.diffIncl = node.currIncl - node.prevIncl;
						node.currCalls = ((DiffDataNode)currKids[idx]).currCalls;
						node.prevCalls = ((DiffDataNode)prevKids[i]).prevCalls;
						node.diffCalls = node.currCalls - node.prevCalls;
						
						node.nodeId = nodeidx;
						node.parentId = parent.nodeId;
						node.parentname = parent.name;
						node.currTreenode = ((DiffDataNode)currKids[idx]).currTreenode;
						node.prevTreenode = ((DiffDataNode)prevKids[i]).prevTreenode;
						node.nodetype = ((DiffDataNode)prevKids[i]).nodetype;

						((DiffDataNode)currKids[idx]).marked = true;
						((DiffDataNode)prevKids[i]).marked = true;
						if(node.diffIncl != 0)
						{
							diffnodes.Add(node);
							AddDiffTraceTableRow(diffTracetbl, node);
							nodeidx++;
						
						}
					}
					else
					{
						long incl = ((DiffDataNode)prevKids[i]).prevIncl;
						prev_inclOfNode[prevKids[i]] = incl; 
						prev.Add(prevKids[i]);
					}
				}
			}
			curr.Sort(new CompareIncl(curr_inclOfNode));
			prev.Sort(new CompareIncl(prev_inclOfNode));
			for(int i = 0; i < curr.Count; i++)
			{
				
				if( !((DiffDataNode)curr[i]).marked)
				{
					DiffDataNode node = new DiffDataNode( ((DiffDataNode)curr[i]).name);
					int idx = FirstMatchIndex(prevKids, curr[i] as DiffDataNode);
					if(idx >=0)
					{
						node.currFunId = ((DiffDataNode)curr[i]).currFunId;
						node.prevFunId = ((DiffDataNode)prevKids[idx]).prevFunId;
						node.mapname = ((DiffDataNode)curr[i]).mapname;
						node.currIncl = ((DiffDataNode)curr[i]).currIncl;
						node.prevIncl = ((DiffDataNode)prevKids[idx]).prevIncl;
						node.diffIncl = node.currIncl - node.prevIncl;
						node.currCalls = ((DiffDataNode)curr[i]).currCalls;
						node.prevCalls = ((DiffDataNode)prevKids[idx]).prevCalls;
						node.diffCalls = node.currCalls - node.prevCalls;
						
						node.nodeId = nodeidx;
						node.parentId = parent.nodeId;
						node.parentname = parent.name;
						node.currTreenode = ((DiffDataNode)curr[i]).currTreenode;
						node.prevTreenode = ((DiffDataNode)prevKids[idx]).prevTreenode;
						node.nodetype = ((DiffDataNode)curr[i]).nodetype;

						((DiffDataNode)curr[i]).marked = true;
						((DiffDataNode)prevKids[idx]).marked = true;
						if(node.diffIncl != 0)
						{
							diffnodes.Add(node);
							AddDiffTraceTableRow(diffTracetbl, node);
							nodeidx++;
						
						}
					}
					else
					{
						node.currFunId = ((DiffDataNode)curr[i]).currFunId;
						node.mapname = ((DiffDataNode)curr[i]).mapname;
						node.currIncl = ((DiffDataNode)curr[i]).currIncl;
						node.prevIncl = 0;
						node.diffIncl = node.currIncl;
						node.currCalls = ((DiffDataNode)curr[i]).currCalls;
						node.prevCalls = 0;
						node.diffCalls = node.currCalls;
						
						node.nodeId = nodeidx;
						node.parentId = parent.nodeId;
						node.parentname = parent.name;
						node.currTreenode = ((DiffDataNode)curr[i]).currTreenode;
						node.nodetype = ((DiffDataNode)curr[i]).nodetype;
						((DiffDataNode)curr[i]).marked = true;
						if(node.diffIncl != 0)
						{
							diffnodes.Add(node);
							AddDiffTraceTableRow(diffTracetbl, node);
							nodeidx++;
						}
					}
				}
				
			}

			for(int i = 0; i < prev.Count; i++)
			{
				if(!((DiffDataNode)prev[i]).marked)
				{
					DiffDataNode node = new DiffDataNode( ((DiffDataNode)prev[i]).name);
					
					// prev not exist in curr
					node.prevFunId = ((DiffDataNode)prev[i]).prevFunId;
					node.mapname = ((DiffDataNode)prev[i]).mapname;
					node.currIncl = 0;
					node.prevIncl = ((DiffDataNode)prev[i]).prevIncl;
					node.diffIncl = -node.prevIncl;
					node.currCalls = 0;
					node.prevCalls = ((DiffDataNode)prev[i]).prevCalls;
					node.diffCalls = -node.prevCalls;
					
					node.nodeId = nodeidx;
					node.parentId = parent.nodeId;
					node.parentname = parent.name;
					node.prevTreenode = ((DiffDataNode)prev[i]).prevTreenode;
					node.nodetype = ((DiffDataNode)prev[i]).nodetype;

					((DiffDataNode)prev[i]).marked = true;
					if(node.diffIncl != 0)
					{
						diffnodes.Add(node);
						AddDiffTraceTableRow(diffTracetbl, node);
						nodeidx++;
					}
				}
				
			}
			for(int i = 0; i < currKids.Count; i++)
			{
				((DiffDataNode)currKids[i]).marked = false;
			}
			for(int i = 0; i < prevKids.Count; i++)
			{
				((DiffDataNode)prevKids[i]).marked = false;
			}

			return diffnodes;
		}
Esempio n. 16
0
		private ArrayList TransPrevTree(ArrayList treeNode)
		{
			ArrayList diffnodes = new ArrayList();
			int functionId = 0;
			int [] kidStacktrace;
			
			for( int i = 0; i < treeNode.Count; i++)
			{
				TreeNode kidNode = treeNode[i] as TreeNode;
				if(kidNode.data.bytesAllocated >0)
				{
					
					kidStacktrace = _prevcallTrace.IndexToStacktrace(kidNode.stackid);
					if (kidNode.nodetype == TreeNode.NodeType.Call)
					{
						functionId = kidStacktrace[ kidStacktrace.Length - 1 ];
					}
					else if (kidNode.nodetype == TreeNode.NodeType.Allocation)
					{
						functionId = kidStacktrace[ 0 ];
					
					}
				
					string name = _prevcallTrace.MakeName(kidNode);
					DiffDataNode node = new DiffDataNode(name);
					node.prevIncl = kidNode.data.bytesAllocated;
					node.prevCalls = kidNode.data.numberOfFunctionsCalled;
				
				
					node.prevTreenode = kidNode;
					node.nodetype = (DiffDataNode.NodeType)kidNode.nodetype;
					
					switch(node.nodetype)
					{
						case DiffDataNode.NodeType.Allocation:
							node.prevFunId = functionId;
							break;

						case DiffDataNode.NodeType.Call:
							node.prevFunId= functionId;
							node.mapname = _prevcallTrace.names[functionId];
							string sig = _prevcallTrace.signatures[functionId];
							if(sig != null)
							{
								node.mapname += ' ' + sig;
							}
							break;
					}
					diffnodes.Add(node);
				
				}
			}

			return diffnodes;
		}
Esempio n. 17
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);
        }
Esempio n. 18
0
		internal DiffDataNode Row2Node(DataRow r)
		{
			string name = r[idx_name].ToString();
			DiffDataNode node = new DiffDataNode(name); 
			
			node.mapname = r[idx_mapname].ToString();
				
			node.prevIncl = int.Parse(r[idx_prevIncl].ToString());
			node.currIncl = int.Parse(r[idx_currIncl].ToString());
			node.diffIncl = int.Parse(r[idx_diffIncl].ToString());
			node.prevFunId = int.Parse(r[idx_prevFunid].ToString());
			node.currFunId = int.Parse(r[idx_currFunid].ToString());
			node.prevCalls = int.Parse(r[idx_prevCalls].ToString());
			node.currCalls = int.Parse(r[idx_currCalls].ToString());
			node.diffCalls = int.Parse(r[idx_diffCalls].ToString());
			int nodetype = int.Parse(r[idx_type].ToString());
			if(nodetype == 0)
			{
				node.nodetype = DiffDataNode.NodeType.Call;
			}
			else if(nodetype == 1)
			{
				node.nodetype = DiffDataNode.NodeType.Allocation;
			}
			else
			{
				node.nodetype = DiffDataNode.NodeType.AssemblyLoad;
			}
				
			node.nodeId = int.Parse(r[idx_id].ToString());
			node.parentId = int.Parse(r[idx_parentid].ToString());
			node.depth = int.Parse(r[idx_depth].ToString());
			return node;
		}
Esempio n. 19
0
		private void AddDiffTraceTableRow(DataTable tmptbl, DiffDataNode node)
		{			
			DataRow tmpRow = tmptbl.NewRow();

			tmpRow["parentid"] = node.parentId;
			tmpRow["id"] = node.nodeId;
			tmpRow["parentname"] = node.parentname;
			tmpRow["name"] = node.name;
			tmpRow["mapname"] = node.mapname;
			tmpRow["prevIncl"] = node.prevIncl;
			tmpRow["currIncl"] = node.currIncl;
			tmpRow["prevCalls"] = node.prevCalls;
			tmpRow["currCalls"] = node.currCalls;
			tmpRow["prevFunId"] = node.prevFunId;
			tmpRow["currFunId"] = node.currFunId;
			if(node.nodetype == DiffDataNode.NodeType.Call)
			{
				tmpRow["nodetype"] = 0;
			}
			else if(node.nodetype == DiffDataNode.NodeType.Allocation)
			{
				tmpRow["nodetype"] = 1;
			}
			else if(node.nodetype == DiffDataNode.NodeType.AssemblyLoad)
			{
				tmpRow["nodetype"] = 2;
			}
			tmpRow["depth"] = node.depth;
			tmptbl.Rows.Add(tmpRow);
			
		}
Esempio n. 20
0
		private void GetLogData()
		{
			// get base data from log files
			try
			{
				_prevLog.readLogFile();
			}
			catch
			{
				throw new Exception("Bad log file: " + _prevLog.LogFileName + "\n");
			}
			try
			{
				_currLog.readLogFile();
			}
			catch
			{
				throw new Exception("Bad log file: " + _currLog.LogFileName +  "\n");
			}

			// get mixed data structure graph
			try
			{
				_prevG.GetAllocationGraph(_prevLog.logResult);
			}
			catch
			{
				throw new Exception("Bad data structure in log file: " + _prevLog.LogFileName +  "\n");
			}
			try
			{
				_currG.GetAllocationGraph(_currLog.logResult);
			}
			catch
			{
				throw new Exception("Bad data structure in log file: " + _currLog.LogFileName +  "\n");
			}

			// get more detailed allocation info from stack trace 
			try
			{
				
				_prevcallTrace = new CallTreeForm(_prevLog.LogFileName, _prevLog.logResult, true);
				ReadFile(_prevcallTrace, _prevLog.LogFileName, this.prevFuncExcl, this.prevTypeExcl);
			}
			catch
			{
				throw new Exception("Bad stacktrace content in log file: " + _prevLog.logResult +  "\n");
			}
			try
			{
				_currcallTrace = new CallTreeForm(_currLog.LogFileName, _currLog.logResult, true);
				ReadFile(_currcallTrace, _currLog.LogFileName, this.currFuncExcl, this.currTypeExcl);
			}
			catch
			{
				throw new Exception("Bad stacktrace content in log file: " + _currLog.logResult +  "\n");
			}
			nodeidx = 0;
			diffTracetbl = new DataTable("diffTrace");
			summaryTracetbl = new DataTable("summaryTracetbl");
			MakeDiffTreceTable(diffTracetbl);
			MakeDiffTreceTable(summaryTracetbl);
		

			string rname = _currcallTrace.MakeName((TreeNode)_currcallTrace.callTreeView.Root);
			Root = new DiffDataNode(rname);
			Root.prevIncl = ((TreeNode)_prevcallTrace.callTreeView.Root).data.bytesAllocated;
			Root.currIncl = ((TreeNode)_currcallTrace.callTreeView.Root).data.bytesAllocated;
			Root.diffIncl = Root.currIncl - Root.prevIncl;
			Root.prevCalls = ((TreeNode)_prevcallTrace.callTreeView.Root).data.numberOfFunctionsCalled;
			Root.currCalls = ((TreeNode)_currcallTrace.callTreeView.Root).data.numberOfFunctionsCalled;
			Root.diffCalls = Root.currCalls - Root.prevCalls;
			

			Root.nodeId = nodeidx++;
			Root.parentId = -1;
			Root.prevFunId = 0;
			Root.currFunId = 0;
			AddDiffTraceTableRow(diffTracetbl, Root);

			
			BuildDiffTraceTable(Root, (TreeNode)_currcallTrace.callTreeView.Root, (TreeNode)_prevcallTrace.callTreeView.Root);
			this.ds.Tables.Add(diffTracetbl);
			sumnodeidx = 0;
			depth = -1;
			BuildSummaryTable(Root, -1, "parentid = -1");
			Root = (DiffDataNode)Root.allkids[0];
			this.ds.Tables.Add(summaryTracetbl);

		

		}
Esempio n. 21
0
		internal DiffStatistics(DiffDataNode node)
		{
			this.node = node;
			
			firstTimeBroughtIn = false;
		}
Esempio n. 22
0
        private void ViewCallTrace([NotNull] string name, int prevIncl, int currIncl, int diffIncl)
        {
            if (name == "<root>")
            {
                diffcallTreeForm = new DiffCallTreeForm(_allocDiff.Root, _allocDiff);
                return;
            }

            var root = new DiffDataNode(name);

            root.mapname   = name;
            root.prevIncl  = prevIncl;
            root.currIncl  = currIncl;
            root.diffIncl  = diffIncl;
            root.currFunId = -1;
            root.prevFunId = -1;

            var tmproot = new DiffDataNode(name);

            tmproot.mapname = name;
            string filter = null;

            DataRow[] rRoot = null;

            if (_allocDiff._currcallTrace.LogResult.allocatedHistogram.readNewLog.funcSignatureIdHash.ContainsKey(name))
            {
                root.currFunId = _allocDiff._currcallTrace.LogResult.allocatedHistogram.readNewLog.funcSignatureIdHash[name];
            }
            if (_allocDiff._prevcallTrace.LogResult.allocatedHistogram.readNewLog.funcSignatureIdHash.ContainsKey(name))
            {
                root.prevFunId = _allocDiff._prevcallTrace.LogResult.allocatedHistogram.readNewLog.funcSignatureIdHash[name];
            }
            if (!(root.prevFunId == -1 && root.currFunId == -1))
            {
                filter = "(prevIncl = " + prevIncl + ") and (currIncl = " + currIncl + ") and (prevFunId = " + root.prevFunId + ") and (currFunId = " + root.currFunId + ")";
                rRoot  = _allocDiff.summaryTracetbl.Select(filter, "depth asc");

                if (rRoot.Length == 0)
                {
                    filter = "(prevFunId = " + root.prevFunId + ") or (currFunId = " + root.currFunId + ")";
                    rRoot  = _allocDiff.summaryTracetbl.Select(filter, "depth asc");

                    if (rRoot.Length == 0)
                    {
                        filter = "(currFunId = " + root.currFunId + ") and (prevFunId = -1)";
                        rRoot  = _allocDiff.summaryTracetbl.Select(filter, "depth asc");

                        if (rRoot.Length == 0)
                        {
                            filter = "(prevFunId = " + root.prevFunId + ") and (currFunId = -1)";
                            rRoot  = _allocDiff.summaryTracetbl.Select(filter, "depth asc");
                            if (rRoot.Length == 0)
                            {
                                filter = null;
                            }
                        }
                    }
                }
            }

            if (filter != null)
            {
                string diffkey;
                if (rRoot.Length == 1)
                {
                    tmproot = _allocDiff.Row2Node(rRoot[0]);
                    diffkey = tmproot.mapname + tmproot.prevIncl + tmproot.currIncl + tmproot.diffIncl + tmproot.prevFunId + tmproot.currFunId;
                    root    = _allocDiff.diffCallTreeNodes[diffkey] as DiffDataNode;
                }
                else if (rRoot.Length > 1)
                {
                    long   sum      = 0;
                    string depth    = null;
                    long   diffincl = 0;
                    var    depLst   = new Hashtable();
                    var    depSum   = new Hashtable();
                    for (int i = 0; i < rRoot.Length; i++)
                    {
                        depth    = rRoot[i][idx_depth].ToString();
                        diffincl = long.Parse(rRoot[i][idx_diffIncl].ToString());
                        sum     += diffincl;
                        if (depLst.Contains(depth))
                        {
                            var alst = (List <DataRow>)depLst[depth];
                            alst.Add(rRoot[i]);
                            depLst[depth] = alst;
                            diffincl     += (long)depSum[depth];
                        }
                        else
                        {
                            var alst = new List <DataRow>();
                            alst.Add(rRoot[i]);
                            depLst.Add(depth, alst);
                            depSum.Add(depth, diffincl);
                        }
                        if (diffincl == root.diffIncl)
                        {
                            break;
                        }
                    }

                    Debug.Assert(root.allkids != null);
                    if (sum != root.diffIncl && diffincl == root.diffIncl)
                    {
                        Debug.Assert(depth != null);
                        if (depLst.ContainsKey(depth))
                        {
                            var lst = (List <DataRow>)depLst[depth];
                            for (int i = 0; i < lst.Count; i++)
                            {
                                var r = lst[i];
                                tmproot = _allocDiff.Row2Node(r);
                                diffkey = tmproot.mapname + tmproot.prevIncl + tmproot.currIncl + tmproot.diffIncl + tmproot.prevFunId + tmproot.currFunId;
                                var subRoot = (DiffDataNode)_allocDiff.diffCallTreeNodes[diffkey];
                                root.allkids.Add(subRoot);
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < rRoot.Length; i++)
                        {
                            tmproot = _allocDiff.Row2Node(rRoot[i]);
                            if (tmproot.depth > 0)
                            {
                                diffkey = tmproot.mapname + tmproot.prevIncl + tmproot.currIncl + tmproot.diffIncl + tmproot.prevFunId + tmproot.currFunId;
                                var subRoot = (DiffDataNode)_allocDiff.diffCallTreeNodes[diffkey];
                                root.allkids.Add(subRoot);
                            }
                        }
                    }
                    root.HasKids = true;
                    root.depth   = 0;
                }
                diffcallTreeForm.Close();
                diffcallTreeForm = new DiffCallTreeForm(root, _allocDiff);
            }
        }