Ejemplo n.º 1
0
        public static FramePack Create(DataResponse response, EventDescriptionBoard board)
        {
            FramePack pack = new FramePack();

            pack.Response = response;

            int frameCount = response.Reader.ReadInt32();

            for (int frame = 0; frame < frameCount; ++frame)
            {
                FrameList list = new FrameList();
                list.FrameType = (FrameList.Type)frame;
                int count = response.Reader.ReadInt32();
                for (int i = 0; i < count; ++i)
                {
                    FrameData frameData = FrameData.Read(response, board);
                    if (frameData.IsNonZero)
                    {
                        list.Events.Add(frameData);
                    }
                }
                pack.Threads.Add(list);
            }
            return(pack);
        }
Ejemplo n.º 2
0
        public void Load(Origin origin = Origin.MainThread)
        {
            Samples = new List <Sample>();

            if (origin == Origin.MainThread)
            {
                Group.UpdateDescriptionMask(Description);

                if (Description.Mask != null)
                {
                    FrameList frameList = Group.GetFocusThread(Description.Mask.Value);
                    if (frameList != null)
                    {
                        List <FrameData> frames = frameList.Events;

                        for (int i = 0; i < frames.Count; ++i)
                        {
                            Sample sample = new Sample()
                            {
                                Name = String.Format("Frame {0:000}", i), Index = i
                            };

                            long start  = frames[i].Start;
                            long finish = i == frames.Count - 1 ? frames[i].Finish : frames[i + 1].Start;

                            foreach (ThreadData thread in Group.Threads)
                            {
                                Utils.ForEachInsideIntervalStrict(thread.Events, start, finish, (frame) =>
                                {
                                    List <Entry> shortEntries = null;
                                    if (frame.ShortBoard.TryGetValue(Description, out shortEntries))
                                    {
                                        foreach (Entry e in shortEntries)
                                        {
                                            sample.Add(e);
                                        }
                                    }
                                });
                            }

                            Samples.Add(sample);
                        }
                    }
                    else
                    {
                        // Fallback to Individual Calls
                        Load(Origin.IndividualCalls);
                    }
                }
            }

            if (origin == Origin.IndividualCalls)
            {
                foreach (ThreadData thread in Group.Threads)
                {
                    foreach (EventFrame frame in thread.Events)
                    {
                        List <Entry> shortEntries = null;
                        if (frame.ShortBoard.TryGetValue(Description, out shortEntries))
                        {
                            foreach (Entry e in shortEntries)
                            {
                                Samples.Add(new Sample(e)
                                {
                                    Index = Samples.Count, Name = Description.Name
                                });
                            }
                        }
                    }
                }

                Samples.Sort((a, b) => (a.Entries[0].CompareTo(b.Entries[0])));
            }
        }