示例#1
0
        public void Serialize(BinaryReader reader, ProfileEventData data)
        {
            m_NbProfiles = reader.ReadUInt32();
            m_ThreadID   = reader.ReadUInt32();
            m_NbEvents   = reader.ReadUInt32();

            // read all the profiles
            EventFileProfileDesc profileDesc = new EventFileProfileDesc();

            for (int i = 0; i < m_NbProfiles; i++)
            {
                profileDesc.Serialize(reader);
                data.AddProfile(profileDesc.m_ProfileID, profileDesc.m_Name);
            }

            ProfileEventData.ProfileContext eventsContext = data.GetEventContext(m_ThreadID);

            // read all the events
            ProfileEvent profileEvent = new ProfileEvent();

            for (int i = 0; i < m_NbEvents; i++)
            {
                profileEvent.Serialize(reader);

                string name = data.GetProfileName(profileEvent.m_ProfileID);
                eventsContext.AddEvent(profileEvent.m_Time, profileEvent.m_ProfileID, profileEvent.m_Type);
            }

            // Send stop events with the last recorded time
            while (!eventsContext.IsTerminated)
            {
                eventsContext.AddEvent(profileEvent.m_Time, 0, ProfileEventData.ProfileContext.Event.EventStop);
            }
        }
        private void ComputeContextSelectionTimes(ProfileEventData.ProfileContext context, ProfileEventData.ProfileContext.Event profileEvent)
        {
            if (profileEvent.Inside(m_RangeStart, m_RangeEnd))
            {
                // Only consider the included time
                Time start = profileEvent.Time;
                Time end   = profileEvent.Time + profileEvent.Length;

                if (start < m_RangeStart)
                {
                    start = m_RangeStart;
                }
                if (end > m_RangeEnd)
                {
                    end = m_RangeEnd;
                }

                // Add
                // profileEvent.m_ProfileID += end-start;
                SelectionInfo oldVal = (SelectionInfo)m_SelectionTimes[profileEvent.ProfileID];
                if (oldVal.m_context.ContainsKey(context.Name) == false)
                {
                    oldVal.m_context.Add(context.Name, new SelectionInfoContext((end - start), 1));
                }
                else
                {
                    SelectionInfoContext selContext;
                    selContext              = (SelectionInfoContext)oldVal.m_context[context.Name];
                    selContext.m_TotalTime += (end - start);
                    selContext.m_Calls++;
                    oldVal.m_context[context.Name] = selContext;
                }

                m_SelectionTimes[profileEvent.ProfileID] = oldVal;
                // Childs
                if (profileEvent.Child != null)
                {
                    ProfileEventData.ProfileContext.Event child = profileEvent.Child;

                    while (child != null)
                    {
                        ComputeContextSelectionTimes(context, child);
                        child = child.Sibling;
                    }
                }
            }
        }