Example #1
0
        public SynchronizationMap(DataResponse response, FrameGroup group)
        {
            Response = response;
            SyncMap  = new Dictionary <UInt64, Synchronization>();

            int count = response.Reader.ReadInt32();
            List <SyncEvent> events = new List <SyncEvent>(count);

            for (int i = 0; i < count; ++i)
            {
                events.Add(new SyncEvent(response.Reader));
            }

            events.Sort();

            for (int i = 0; i < count; ++i)
            {
                SyncEvent scEvent = events[i];

                if (scEvent.OldThreadID != 0)
                {
                    Synchronization oldSync = null;
                    if (!SyncMap.TryGetValue(scEvent.OldThreadID, out oldSync))
                    {
                        oldSync = new Synchronization();
                        SyncMap.Add(scEvent.OldThreadID, oldSync);
                    }

                    if (oldSync.Count > 0)
                    {
                        SyncInterval interval = oldSync[oldSync.Count - 1];
                        interval.Reason      = scEvent.Reason;
                        interval.Finish      = scEvent.Timestamp.Start;
                        interval.NewThreadId = scEvent.NewThreadID;
                    }
                }

                if (scEvent.NewThreadID != 0)
                {
                    Synchronization newSync = null;
                    if (!SyncMap.TryGetValue(scEvent.NewThreadID, out newSync))
                    {
                        newSync = new Synchronization();
                        SyncMap.Add(scEvent.NewThreadID, newSync);
                    }

                    SyncInterval data = new SyncInterval()
                    {
                        Start  = scEvent.Timestamp.Start,
                        Finish = long.MaxValue,
                        Core   = scEvent.CPUID,
                    };

                    while (newSync.Count > 0)
                    {
                        SyncInterval previous = newSync[newSync.Count - 1];
                        if (previous.Finish <= data.Start)
                        {
                            break;
                        }

                        newSync.RemoveAt(newSync.Count - 1);
                    }

                    newSync.Add(data);
                }
            }
        }
Example #2
0
        public static EventDescriptionBoard Read(DataResponse response)
        {
            BinaryReader reader = response.Reader;

            EventDescriptionBoard desc = new EventDescriptionBoard();

            desc.Response   = response;
            desc.BaseStream = reader.BaseStream;
            desc.ID         = reader.ReadInt32();

            desc.TimeSettings              = new TimeSettings();
            desc.TimeSettings.TicksToMs    = 1000.0 / (double)reader.ReadInt64();
            desc.TimeSettings.Origin       = reader.ReadInt64();
            desc.TimeSettings.PrecisionCut = reader.ReadInt32();
            Durable.InitSettings(desc.TimeSettings);

            desc.TimeSlice = new Durable();
            desc.TimeSlice.ReadDurable(reader);

            int threadCount = reader.ReadInt32();

            desc.Threads = new List <ThreadDescription>(threadCount);
            desc.ThreadID2ThreadIndex = new Dictionary <UInt64, int>();

            for (int i = 0; i < threadCount; ++i)
            {
                ThreadDescription threadDesc = ThreadDescription.Read(response);
                desc.Threads.Add(threadDesc);

                if (!desc.ThreadID2ThreadIndex.ContainsKey(threadDesc.ThreadID))
                {
                    desc.ThreadID2ThreadIndex.Add(threadDesc.ThreadID, i);
                }
                else
                {
                    // The old thread was finished and the new thread was started
                    // with the same threadID during one profiling session.
                    // Can't do much here - lets show information for the new thread only.
                    desc.ThreadID2ThreadIndex[threadDesc.ThreadID] = i;
                }
            }

            if (response.ApplicationID == NetworkProtocol.BROFILER_APP_ID)
            {
                int fibersCount = reader.ReadInt32();
                desc.Fibers = new List <FiberDescription>(fibersCount);
                for (int i = 0; i < fibersCount; ++i)
                {
                    FiberDescription fiberDesc = FiberDescription.Read(response);
                    desc.Fibers.Add(fiberDesc);
                }
            }

            desc.MainThreadIndex = reader.ReadInt32();

            int count = reader.ReadInt32();

            for (int i = 0; i < count; ++i)
            {
                desc.board.Add(EventDescription.Read(reader, i));
            }

            // TODO: Tags

            // TODO: Run Info

            // TODO: Run Info

            // TODO: Filters

            // TODO: Mode

            // TODO: Thread Descriptions

            return(desc);
        }
Example #3
0
        public static DataResponse Create(String base64)
        {
            MemoryStream stream = new MemoryStream(Convert.FromBase64String(base64));

            return(DataResponse.Create(stream));
        }
Example #4
0
 public Frame(DataResponse response, FrameGroup group)
 {
     Group    = group;
     Response = response;
 }
Example #5
0
        public static EventDescriptionBoard Read(DataResponse response)
        {
            BinaryReader reader = response.Reader;

            EventDescriptionBoard desc = new EventDescriptionBoard();

            desc.Response   = response;
            desc.BaseStream = reader.BaseStream;
            desc.ID         = reader.ReadInt32();

            desc.TimeSettings              = new TimeSettings();
            desc.TimeSettings.TicksToMs    = 1000.0 / (double)reader.ReadInt64();
            desc.TimeSettings.Origin       = reader.ReadInt64();
            desc.TimeSettings.PrecisionCut = reader.ReadInt32();
            Durable.InitSettings(desc.TimeSettings);

            desc.TimeSlice = new Durable();
            desc.TimeSlice.ReadDurable(reader);

            int threadCount = reader.ReadInt32();

            desc.Threads = new List <ThreadDescription>(threadCount);
            desc.ThreadID2ThreadIndex = new Dictionary <UInt64, int>();

            for (int i = 0; i < threadCount; ++i)
            {
                ThreadDescription threadDesc = ThreadDescription.Read(response);
                threadDesc.Origin      = ThreadDescription.Source.Game;
                threadDesc.ThreadIndex = i;
                desc.Threads.Add(threadDesc);

                if (!desc.ThreadID2ThreadIndex.ContainsKey(threadDesc.ThreadID))
                {
                    desc.ThreadID2ThreadIndex.Add(threadDesc.ThreadID, i);
                    desc.ThreadDescriptions.Add(threadDesc.ThreadID, threadDesc);
                }
                else
                {
                    // The old thread was finished and the new thread was started
                    // with the same threadID during one profiling session.
                    // Can't do much here - lets show information for the new thread only.
                    desc.ThreadID2ThreadIndex[threadDesc.ThreadID] = i;
                }
            }

            if (response.ApplicationID == NetworkProtocol.OPTICK_APP_ID)
            {
                int fibersCount = reader.ReadInt32();
                desc.Fibers = new List <FiberDescription>(fibersCount);
                for (int i = 0; i < fibersCount; ++i)
                {
                    FiberDescription fiberDesc = FiberDescription.Read(response);
                    desc.Fibers.Add(fiberDesc);
                }
            }

            desc.MainThreadIndex = reader.ReadInt32();

            int count = reader.ReadInt32();

            for (int i = 0; i < count; ++i)
            {
                desc.board.Add(EventDescription.Read(reader, i));
            }

            // TODO: Tags
            reader.ReadUInt32();

            // TODO: Run Info
            reader.ReadUInt32();

            // TODO: Run Info
            reader.ReadUInt32();

            // TODO: Filters
            reader.ReadUInt32();

            // TODO: Mode
            desc.Mode = reader.ReadUInt32();

            // TODO: Thread Descriptions
            int processDescCount = reader.ReadInt32();

            for (int i = 0; i < processDescCount; ++i)
            {
                ProcessDescription process = ProcessDescription.Read(response);
                if (!desc.ProcessDescritpions.ContainsKey(process.ProcessID))
                {
                    desc.ProcessDescritpions.Add(process.ProcessID, process);
                }
            }

            int threadDescCount = reader.ReadInt32();

            for (int i = 0; i < threadDescCount; ++i)
            {
                ThreadDescription thread = ThreadDescription.Read(response);
                thread.Origin = ThreadDescription.Source.GameAuto;
                if (!desc.ThreadDescriptions.ContainsKey(thread.ThreadID))
                {
                    desc.ThreadDescriptions.Add(thread.ThreadID, thread);
                }
                //else if (!String.IsNullOrEmpty(thread.Name))
                //	desc.ThreadDescriptions[thread.ThreadID] = thread;

                ProcessDescription process = null;
                if (desc.ProcessDescritpions.TryGetValue(thread.ProcessID, out process))
                {
                    thread.Process = process;
                }
            }

            desc.ProcessID    = response.Reader.ReadInt32();
            desc.CPUCoreCount = response.Reader.ReadInt32();

            return(desc);
        }
Example #6
0
        public EventFrame(DataResponse response, FrameGroup group) : base(response, group)
        {
            BinaryReader reader = response.Reader;

            ReadInternal(response);
        }
Example #7
0
 public EventFrame(DataResponse response, FrameGroup group) : base(response)
 {
     reader = response.Reader;
     Group  = group;
     ReadInternal(reader);
 }
Example #8
0
 public SamplingFrame(DataResponse response, FrameGroup group) : base(response, group)
 {
     SampleCount = response.Reader.ReadInt32();
 }
Example #9
0
 public SamplingFrame(DataResponse response) : base(response)
 {
     Reader      = response.Reader;
     SampleCount = Reader.ReadInt32();
 }
Example #10
0
 public Frame(DataResponse response)
 {
     Response = response;
 }