示例#1
0
            //==================================================
            public void addAcccumulatedSamples(List <allocTreeSampleData> accumulator, bool useOriginalSamples)
            {
                // [12/3/2008 Xemu] add our contribution to the accumulation
                List <allocTreeSampleData> useSamples = null;

                if (useOriginalSamples)
                {
                    useSamples = samples;
                }
                else
                {
                    useSamples = accumulatedSamples;
                }

                if (useSamples == null)
                {
                    return;
                }

                foreach (allocTreeSampleData s in useSamples)
                {
                    int matchSample = s.sampleIndex;

                    // [12/3/2008 Xemu] find the matching accumulator entry
                    bool found = false;

                    foreach (allocTreeSampleData sampleData in accumulator)
                    {
                        if (sampleData.sampleIndex == matchSample)
                        {
                            if (s.size < 0)
                            {
                                Debugger.Break();
                            }
                            sampleData.size += s.size;
                            found            = true;
                            break;
                        }
                    }

                    // [12/3/2008 Xemu] add it into the accumulator if no match found
                    if (!found)
                    {
                        allocTreeSampleData asd = new allocTreeSampleData();
                        asd.size        = s.size;
                        asd.sampleIndex = s.sampleIndex;
                        accumulator.Add(asd);
                    }
                }
            }
示例#2
0
 //==================================================
 private static int SortBySamples(allocTreeSampleData x, allocTreeSampleData y)
 {
     if (x.sampleIndex < y.sampleIndex)
     {
         return(-1);
     }
     else if (x.sampleIndex > y.sampleIndex)
     {
         return(1);
     }
     else
     {
         return(0);
     }
 }
示例#3
0
        //==================================================
        void populateTreeView(memStatsXML fsXML)
        {
            allocTreeNode tnRootNode = new allocTreeNode();

            tnRootNode.function  = "ALL";
            tnRootNode.file      = "";
            tnRootNode.line      = "";
            tnRootNode.allocSize = 0;


            for (int allocIndex = 0; allocIndex < fsXML.allocations.Count; allocIndex++)
            {
                allocXML alloc     = fsXML.allocations[allocIndex];
                int      allocSize = int.Parse(alloc.size);

                int stackIndex = 0;

                allocTreeNode lastNode = tnRootNode;
                bool          added    = false;
                while (stackIndex < alloc.stack.Count)
                {
                    bool found = false;
                    for (int i = 0; i < lastNode.Nodes.Count; i++)
                    {
                        allocTreeNode node = lastNode.Nodes[i] as allocTreeNode;
                        if (node == null)
                        {
                            continue;
                        }

                        if (node.function == alloc.stack[stackIndex].function)
                        {
                            lastNode = node;
                            stackIndex++;
                            found = true;
                            break;
                        }
                    }

                    //we didn't find ourselves at this node, add us.
                    if (!found)
                    {
                        added = true;
                        allocTreeNode atn = new allocTreeNode();
                        atn.function  = alloc.stack[stackIndex].function;
                        atn.file      = alloc.stack[stackIndex].file;
                        atn.line      = alloc.stack[stackIndex].line;
                        atn.allocSize = allocSize;
                        atn.samples   = new List <allocTreeSampleData>();
                        foreach (sizeSampleXML sample in alloc.sizeSamples)
                        {
                            allocTreeSampleData sampleData = new allocTreeSampleData();
                            sampleData.size        = Int32.Parse(sample.size);
                            sampleData.sampleIndex = Int32.Parse(sample.sample);
                            atn.samples.Add(sampleData);
                        }
                        atn.samples.Sort(SortBySamples);

                        lastNode.Nodes.Add(atn);
                        stackIndex++;
                        lastNode = (allocTreeNode)lastNode.Nodes[lastNode.Nodes.Count - 1];
                    }
                }


                //if we never added, then this is a duplicate path, so add our memory to the leaf node
                if (!added)
                {
                    lastNode.allocSize += allocSize;
                }
            }

            updateTreeNodes(tnRootNode);
            removeFilteredNodes(tnRootNode);
            sortTreeNodes(tnRootNode);
            treeView1.Nodes.Clear();
            treeView1.Nodes.Add(tnRootNode);
        }