コード例 #1
0
        public List <NodeFrameEntry[]> GetNodeFrameStats(IList <int> nodeIds)
        {
            var idLookup = new byte[Names.Length];
            int countId  = 1;// Skip zero we default to that slot for non interesting nodes

            foreach (var id in nodeIds)
            {
                idLookup[id] = (byte)countId++;
            }

            var stats = new NodeFrameEntry[nodeIds.Count][];

            for (int i = 1; i < nodeIds.Count; i++)
            {
                stats[i] = new NodeFrameEntry[NodeStatsLookup[nodeIds[i - 1]].FrameCount];
            }

            var count = new int[nodeIds.Count];

            for (int j = 0; j < Frames.Count; j++)
            {
                var frame = Frames[j];
                var calls = frame.Calls;

                var threadI     = 0;
                int threadLimit = frame.Threads.First().EndIndex;

                for (int i = 1; i < calls.Length; i++)
                {
                    int id            = calls[i].ppid;
                    var exclusiveTime = calls[i].ExclusiveTime;

                    var slot = idLookup[id];

                    if (slot != 0)
                    {
                        int index = count[slot];
                        var array = stats[slot];
                        array[index].InclusiveTotal += calls[i].Time;
                        array[index].Frame           = frame;
                        array[index].RawTime        += calls[i].ExclusiveTime;
                        array[index].CallCount      += calls[i].ExclusiveTime;

                        // curr.Percent += (float)(calls[i].ExclusiveTime / (double)frame.Threads[threadI].Time);
                    }
                }
            }

            return(stats.Skip(1).ToList());
        }
コード例 #2
0
        public List <NodeFrameEntry> GetNodeFrameStats(int nodeId, int startFrame = -1, int frameCount = -1, int threadId = -1)
        {
            var stats  = NodeStatsLookup[nodeId];
            var result = new List <NodeFrameEntry>(stats.FrameCount);

            if (startFrame == -1)
            {
                startFrame = 0;
            }

            if (frameCount == -1)
            {
                frameCount = Frames.Count;
            }
            else
            {
                frameCount += startFrame;
            }

            for (int j = startFrame; j < frameCount; j++)
            {
                var frame = Frames[j];
                var calls = frame.Calls;

                var threadI = 0;
                var thread  = frame.Threads.First();

                //Filter to only nodes that are children of the the thread with the matching name id
                if (threadId != -1)
                {
                    thread = frame.Threads.FirstOrDefault(t => t.NameId == threadId);
                    if (thread == null)
                    {
                        continue;
                    }
                }

                int threadLimit = thread.EndIndex;

                var  curr = new NodeFrameEntry();
                bool seen = false;

                for (int i = 1; i < calls.Length; i++)
                {
                    int id            = calls[i].ppid;
                    var exclusiveTime = calls[i].ExclusiveTime;

                    if (i == threadLimit)
                    {
                        if (threadId != -1)
                        {
                            break;
                        }
                        threadI++;
                        threadLimit = frame.Threads[threadI].EndIndex;
                    }

                    if (id == nodeId)
                    {
                        seen       = true;
                        curr.Frame = frame;
                        // Inclusive
                        curr.InclusiveTotal += calls[i].Time;
                        curr.RawTime        += calls[i].ExclusiveTime;
                        curr.CallCount      += calls[i].CallCount;
                        if (curr.LastThread != threadI)
                        {
                            curr.ThreadCount++;
                        }
                        curr.LastThread = (byte)threadI;
                        curr.Percent   += (float)(calls[i].ExclusiveTime / (double)frame.Threads[threadI].Time);
                    }
                }

                if (seen)
                {
                    result.Add(curr);
                }
            }

            return(result);
        }