public ValueList BuildValueList(IReadOnlyFRPC dataPaths, IReadOnlyFRPC viewPaths, IEnumerable <string> restrictToViewPaths)
        {
            ValueList vl = new ValueList();

            FillNonLeafValueList(vl, dataPaths, viewPaths, restrictToViewPaths);
            return(vl);
        }
        public DisplayList BuildDisplayList(IReadOnlyFRPC dataPaths)
        {
            DisplayList dl = new DisplayList();

            FillLeafDisplayList(dl, dataPaths);
            return(dl);
        }
        private void FillLeafDisplayList(DisplayList dl, IReadOnlyFRPC dataPaths)
        {
            bool isLeafNode = IsLeaf;

            if (isLeafNode)
            {
                int pathIdx = dataPaths.TryGetIndexFromPath(LeafPath);
                if (pathIdx != -1)
                {
                    dl.Cmds.Add(new DisplayListCmd(dl.Items.Count, 1, this));
                    dl.Items.Add(new ListItem(false, pathIdx, DisplayScale));
                }
            }
            else if (IsCollapsed)
            {
                int firstItem = dl.Items.Count;
                FillListItems(dl.Items, dataPaths);

                int numItems = dl.Items.Count - firstItem;
                if (numItems > 0)
                {
                    dl.Cmds.Add(new DisplayListCmd(firstItem, numItems, this));
                }
            }
            else
            {
                foreach (ProfilerRDI childRdi in Children)
                {
                    if (childRdi.Displayed)
                    {
                        childRdi.FillLeafDisplayList(dl, dataPaths);
                    }
                }
            }
        }
        private void FillNonLeafValueList(ValueList vl, IReadOnlyFRPC dataPaths, IReadOnlyFRPC viewPaths, IEnumerable <string> restrictToViewPaths)
        {
            if (!IsLeaf && (restrictToViewPaths == null || restrictToViewPaths.Contains(LeafPath)))
            {
                int leafViewPathIdx = viewPaths.TryGetIndexFromPath(LeafPath);
                if (leafViewPathIdx != -1)                      // if the LeafPath isn't present in viewPaths, none of the children will be either
                {
                    if (!IsCollapsed)
                    {
                        // Make sure that all non-leaf children are computed first
                        foreach (ProfilerRDI childRdi in Children)
                        {
                            if (!childRdi.IsLeaf)
                            {
                                childRdi.FillNonLeafValueList(vl, dataPaths, viewPaths, restrictToViewPaths);
                            }
                        }

                        // Produce a cmd that accumulates all children - their values should now be valid
                        int firstItem = vl.Items.Count;
                        {
                            foreach (ProfilerRDI childRdi in Children)
                            {
                                if (childRdi.Displayed)
                                {
                                    IReadOnlyFRPC paths   = childRdi.IsLeaf ? dataPaths : viewPaths;
                                    int           pathIdx = paths.TryGetIndexFromPath(childRdi.LeafPath);
                                    if (pathIdx != -1)
                                    {
                                        vl.Items.Add(new ListItem(!childRdi.IsLeaf, pathIdx, childRdi.DisplayScale));
                                    }
                                }
                            }
                        }

                        int numItems = vl.Items.Count - firstItem;
                        vl.Cmds.Add(new ValueListCmd(firstItem, numItems, leafViewPathIdx));
                    }
                    else
                    {
                        int firstItem = vl.Items.Count;
                        FillListItems(vl.Items, dataPaths);

                        int numItems = vl.Items.Count - firstItem;
                        vl.Cmds.Add(new ValueListCmd(firstItem, numItems, leafViewPathIdx));
                    }
                }
            }
        }
Exemple #5
0
        void CalculateValueStats(int fromIdx, int toIdx, IEnumerable <string> restrictToViewPaths)
        {
            int                numTasks      = 32;
            int                numValueStats = m_valueStats.Count;
            int                segmentSize   = (numValueStats / numTasks) + 1;
            MTCounter          counter       = new MTCounter(numValueStats);
            GetValuesFromIndex perViewVFI    = i => m_baseViewFRs[i].Values;
            GetValuesFromIndex perLogVFI     = i => m_baseLogData.FrameRecords[i].Values;

            for (int i = 0; i < numTasks; ++i)
            {
                int start = i * segmentSize;
                int end   = Math.Min(start + segmentSize, numValueStats);

                if (start >= end)
                {
                    break;
                }

                ThreadPool.QueueUserWorkItem((o) =>
                {
                    for (int j = start; j < end; ++j)
                    {
                        string path = m_valueStats.Keys[j];

                        if (restrictToViewPaths != null && !restrictToViewPaths.Contains(path))
                        {
                            continue;
                        }

                        ValueStats valueStats            = m_valueStats.Values[j];
                        IReadOnlyFRPC paths              = valueStats.m_bValueIsPerLogView ? m_viewPaths : m_dataPaths;
                        GetValuesFromIndex valuesFromIdx = valueStats.m_bValueIsPerLogView ? perViewVFI : perLogVFI;
                        CalcSingleValueStat(valueStats, paths.GetIndexFromPath(path), fromIdx, toIdx, valuesFromIdx);
                    }

                    counter.Increment(end - start);
                }
                                             );
            }

            counter.WaitUntilMax();
        }
 private void FillListItems(List <ListItem> items, IReadOnlyFRPC dataPaths)
 {
     if (IsLeaf)
     {
         int pathIdx = dataPaths.TryGetIndexFromPath(LeafPath);
         if (pathIdx != -1)
         {
             items.Add(new ListItem(false, pathIdx, DisplayScale));
         }
     }
     else
     {
         foreach (ProfilerRDI child in Children)
         {
             if (child.Displayed)
             {
                 child.FillListItems(items, dataPaths);
             }
         }
     }
 }