コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: vr3d/brofiler
        void frameTabs_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (frameTabs.SelectedItem is CloseableTabItem)
            {
                var dataContext = (frameTabs.SelectedItem as CloseableTabItem).DataContext;

                if (dataContext is Data.EventFrame)
                {
                    Data.EventFrame frame = dataContext as Data.EventFrame;
                    ThreadView.FocusOn(frame, null);
                }
            }
        }
コード例 #2
0
        void Init()
        {
            if (DataContext is Data.EventFrame)
            {
                Data.EventFrame frame = (Data.EventFrame)DataContext;
                LayoutRoot.Children.Clear();

                double frameStartMS = frame.Header.StartMS;

                foreach (EventNode node in frame.CategoriesTree.Children)
                {
                    InitNode(node, frameStartMS, 0);
                }
            }
        }
コード例 #3
0
        public void Serialize(System.IO.Stream stream)
        {
            HashSet <EventDescriptionBoard> boards = new HashSet <EventDescriptionBoard>();
            HashSet <FrameGroup>            groups = new HashSet <FrameGroup>();

            foreach (Frame frame in this)
            {
                if (frame is EventFrame)
                {
                    EventFrame eventFrame = frame as EventFrame;
                    boards.Add(eventFrame.DescriptionBoard);
                    groups.Add(eventFrame.Group);
                }
            }

            foreach (EventDescriptionBoard board in boards)
            {
                DataResponse.Serialize(DataResponse.Type.FrameDescriptionBoard, board.BaseStream, stream);
            }

            foreach (Frame frame in this)
            {
                DataResponse.Serialize(frame.ResponseType, frame.BaseStream, stream);
            }

            foreach (FrameGroup group in groups)
            {
                for (int threadIndex = 0; threadIndex < group.Threads.Count; ++threadIndex)
                {
                    if (threadIndex != group.Board.MainThreadIndex)
                    {
                        foreach (Frame frame in group.Threads[threadIndex].Events)
                        {
                            DataResponse.Serialize(frame.ResponseType, frame.BaseStream, stream);
                        }
                    }
                }
            }
        }
コード例 #4
0
 public EventTree(EventFrame frame, List <Entry> entries) : base(null, new Entry(null, frame.Start, frame.Finish))
 {
     this.frame = frame;
     BuildTree(entries);
     CalculateRecursiveExcludeFlag(new Dictionary <Object, int>());
 }
コード例 #5
0
ファイル: TraceGroup.cs プロジェクト: weynaa/optick
        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);
        }
コード例 #6
0
ファイル: TraceGroup.cs プロジェクト: weynaa/optick
        public bool Init(String name, Stream stream)
        {
            Durable.InitSettings(Board.TimeSettings);

            String text = new StreamReader(stream).ReadToEnd();

            ChromeTrace trace = JsonConvert.DeserializeObject <ChromeTrace>(text);

            Dictionary <ulong, List <TraceEvent> > threads = new Dictionary <ulong, List <TraceEvent> >();

            foreach (TraceEvent ev in trace.traceEvents)
            {
                // Complete Event
                if (ev.ph == "X")
                {
                    List <TraceEvent> events = null;
                    if (!threads.TryGetValue(ev.tid, out events))
                    {
                        events = new List <TraceEvent>();
                        threads.Add(ev.tid, events);
                    }
                    events.Add(ev);
                }
            }

            Durable range = new Durable(long.MaxValue, long.MinValue);

            Dictionary <string, EventDescription> descriptions = new Dictionary <string, EventDescription>();

            foreach (KeyValuePair <ulong, List <TraceEvent> > pair in threads)
            {
                ulong             tid    = pair.Key;
                List <TraceEvent> events = pair.Value;

                List <Entry> entries = new List <Entry>(events.Count);
                List <Tag>   tags    = new List <Tag>(events.Count);

                foreach (TraceEvent ev in events)
                {
                    String args = ev.args != null?ev.args.ToString().Replace("\n", "").Replace("\r", "") : null;

                    String context   = GenerateShortContext(args);
                    String extraName = GenerateShortName(context);

                    String fullName = ev.name;
                    if (!String.IsNullOrWhiteSpace(extraName))
                    {
                        fullName = String.Format("{0} - {1}", ev.name, extraName);
                    }

                    EventDescription desc = null;
                    if (!descriptions.TryGetValue(fullName, out desc))
                    {
                        desc = new EventDescription(fullName)
                        {
                            Color = EventDescription.GenerateRandomColor(ev.name, RandomColorBrightnessVariance)
                        };
                        descriptions.Add(fullName, desc);
                    }

                    entries.Add(new Entry(desc, (long)ev.ts, (long)(ev.ts + ev.dur)));

                    if (!String.IsNullOrWhiteSpace(context))
                    {
                        tags.Add(new Tag()
                        {
                            Description = new EventDescription(context), Time = new Tick()
                            {
                                Start = (long)ev.ts
                            }
                        });
                    }
                }

                entries.Sort();
                tags.Sort();

                ThreadData threadData = MainGroup.AddThread(new ThreadDescription()
                {
                    Name = String.Format("Thread #{0}", tid), ThreadID = tid, ProcessID = 0, Origin = ThreadDescription.Source.Game
                });
                threadData.TagsPack = new TagsPack(tags);

                EventFrame frame = new EventFrame(new FrameHeader(new Durable(entries.Min(e => e.Start), entries.Max(e => e.Finish)), threadData.Description.ThreadIndex), entries, MainGroup);
                entries.ForEach(e => e.Frame = frame);

                range.Start  = Math.Min(range.Start, frame.Start);
                range.Finish = Math.Max(range.Finish, frame.Finish);

                threadData.Events.Add(frame);
            }

            Board.TimeSlice       = range;
            Board.MainThreadIndex = 0;
            MainFrame             = new EventFrame(new FrameHeader(Board.TimeSlice), new List <Entry> {
            }, MainGroup);

            return(true);
        }
コード例 #7
0
ファイル: EventTree.cs プロジェクト: vr3d/brofiler
 public EventTree(EventFrame frame, List <Entry> entries) : base(null, new Entry(null, frame.Start, frame.Finish))
 {
     this.frame = frame;
     BuildTree(entries);
 }