Esempio n. 1
0
        public static EventDescriptionBoard Read(DataResponse response)
        {
            BinaryReader reader = response.Reader;

            EventDescriptionBoard desc = new EventDescriptionBoard()
            {
                Response = response
            };

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

            desc.Frequency = reader.ReadInt64();
            Durable.InitFrequency(desc.Frequency);

            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;
                }
            }

            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));
            }
            return(desc);
        }
Esempio n. 2
0
        public static EventDescriptionBoard Read(BinaryReader reader)
        {
            EventDescriptionBoard desc = new EventDescriptionBoard();

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

            desc.Frequency = reader.ReadInt64();
            Durable.InitFrequency(desc.Frequency);

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

            int threadCount = reader.ReadInt32();

            desc.Threads = new List <ThreadDescription>(threadCount);

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

            desc.MainThreadIndex = reader.ReadInt32();

            int count = reader.ReadInt32();

            for (int i = 0; i < count; ++i)
            {
                desc.board.Add(EventDescription.Read(reader, i));
            }
            return(desc);
        }
Esempio n. 3
0
        public static ThreadDescription Read(BinaryReader reader)
        {
            ThreadDescription res = new ThreadDescription();

            res.ThreadID = reader.ReadInt32();
            int nameLength = reader.ReadInt32();

            res.Name = new String(reader.ReadChars(nameLength));
            return(res);
        }
Esempio n. 4
0
        public static ThreadDescription Read(DataResponse response)
        {
            BinaryReader      reader = response.Reader;
            ThreadDescription res    = new ThreadDescription();

            res.ThreadID = reader.ReadUInt64();
            int nameLength = reader.ReadInt32();

            res.Name     = new String(reader.ReadChars(nameLength));
            res.MaxDepth = 1; // TODO: reader.ReadInt32();
            return(res);
        }
Esempio n. 5
0
        public static ThreadDescription Read(DataResponse response)
        {
            BinaryReader      reader = response.Reader;
            ThreadDescription res    = new ThreadDescription();

            res.ThreadID  = reader.ReadUInt64();
            res.ProcessID = reader.ReadUInt32();
            res.Name      = Utils.ReadBinaryString(reader);
            res.MaxDepth  = reader.ReadInt32();
            res.Priority  = reader.ReadInt32();
            res.Mask      = reader.ReadInt32();
            return(res);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        public bool Init(String name, Stream stream)
        {
            TextReader reader = new StreamReader(stream);

            List <SyncEvent> events   = new List <SyncEvent>();
            List <TagsPack>  tagPacks = new List <TagsPack>();

            Durable.InitSettings(Board.TimeSettings);

            long minTimestamp = long.MaxValue;
            long maxTimestamp = 0;

            while (true)
            {
                String line = reader.ReadLine();
                if (line == null)
                {
                    break;
                }

                if (line.StartsWith("#"))
                {
                    continue;
                }

                String function = line.Substring(44);
                function = function.Substring(0, function.IndexOf(':')).Trim();

                if (function == "sched_switch")
                {
                    byte core      = byte.Parse(line.Substring(24, 3));
                    long timestamp = (long)(double.Parse(line.Substring(28, 14).Trim()) * 1000000.0);

                    minTimestamp = Math.Min(minTimestamp, timestamp);
                    maxTimestamp = Math.Max(maxTimestamp, timestamp);

                    String prevThread = FindBetween(line, "prev_comm=", "prev_pid=");
                    uint   prevPid    = uint.Parse(FindBetween(line, "prev_pid=", "prev_prio="));
                    uint   prevPrio   = uint.Parse(FindBetween(line, "prev_prio=", "prev_state="));

                    String nextThread = FindBetween(line, "==>", "next_pid=");
                    uint   nextPid    = uint.Parse(FindBetween(line, "next_pid=", "next_prio="));
                    uint   nextPrio   = uint.Parse(FindBetween(line, "next_prio=", null));

                    events.Add(new SyncEvent()
                    {
                        CPUID = core, OldThreadID = prevPid, NewThreadID = nextPid, Timestamp = new Tick()
                        {
                            Start = (long)timestamp
                        }
                    });

                    ThreadDescription desc = null;
                    if (!Board.ThreadDescriptions.TryGetValue(prevPid, out desc))
                    {
                        desc = new ThreadDescription()
                        {
                            Name = prevThread, ThreadID = prevPid, ProcessID = 0, Origin = ThreadDescription.Source.GameAuto
                        };
                        Board.ThreadDescriptions.Add(prevPid, desc);
                    }
                    else
                    {
                        desc.Name = prevThread;
                    }
                }

                if (function == "tracing_mark_write")
                {
                    byte   core      = byte.Parse(line.Substring(24, 3));
                    long   timestamp = (long)(double.Parse(line.Substring(28, 14).Trim()) * 1000000.0);
                    String text      = FindBetween(line, function, null).Substring(2);

                    while (tagPacks.Count <= core)
                    {
                        tagPacks.Add(new TagsPack(null, Group)
                        {
                            CoreIndex = tagPacks.Count
                        });
                    }

                    Tag tag = new TagString()
                    {
                        Description = new EventDescription("Message"), Time = new Tick()
                        {
                            Start = timestamp
                        }, Value = text
                    };
                    tagPacks[core].Tags.Add(tag);
                }
            }

            Board.TimeSlice = new Durable(minTimestamp, maxTimestamp);
            Frame           = new EventFrame(new FrameHeader(Board.TimeSlice), new List <Entry> {
            }, Group);

            List <EventFrame> frames = new List <EventFrame>();
            long step = Durable.MsToTick(1000.0);

            for (long timestamp = minTimestamp; timestamp < maxTimestamp; timestamp += step)
            {
                frames.Add(new EventFrame(new FrameHeader(new Durable(timestamp, timestamp + step)), new List <Entry> {
                }, Group));
            }
            ThreadDescription ruler = new ThreadDescription()
            {
                Name = "Ruler", ThreadIndex = 0
            };

            Group.Threads.Add(new ThreadData(ruler)
            {
                Events = frames
            });
            Group.Board.Threads.Add(ruler);
            Group.Board.MainThreadIndex = 0;

            SynchronizationMap syncMap = new SynchronizationMap(events);

            Group.AddSynchronization(syncMap);

            for (int i = 0; i < Math.Min(tagPacks.Count, Group.Cores.Count); ++i)
            {
                Group.Cores[i].TagsPack = tagPacks[i];
            }

            return(true);
        }