示例#1
0
 public UserMarkerRDI(UserMarkerLocation uml, LogView logView)
     : base(uml.m_path, uml.GetNameForLogView(logView), 1.0f)
 {
     DisplayName = uml.m_name;
     m_uml       = uml;
     m_logView   = logView;
     Unhighlight();
 }
示例#2
0
        public FrameRecord(int index, float frameTimeInS, MemoryStream screenshotImage, IReadOnlyFRVs values, IEnumerable <UserMarker> userMarkers, IEnumerable <Callstack> callstacks)
        {
            Index           = index;
            FrameTimeInS    = frameTimeInS;
            FrameMidTimeInS = frameTimeInS;
            ScreenshotImage = screenshotImage;
            Values          = values;

            List <UserMarkerLocation> userMarkerLocs = new List <UserMarkerLocation>();

            foreach (UserMarker userMarker in userMarkers)
            {
                UserMarkerLocation userMarkerLocation = new UserMarkerLocation(userMarker, this, userMarkerLocs.Count);
                userMarkerLocs.Add(userMarkerLocation);
            }

            UserMarkers = userMarkerLocs;

            Callstacks = callstacks;
        }
示例#3
0
        public UserMarkerRDI GetIfDisplayed(UserMarkerLocation uml, LogView logView)
        {
            UserMarkerRDI umrdi = this;

            if (!umrdi.Displayed)
            {
                return(null);
            }

            string[] locations = uml.m_path.PathLocations();
            foreach (string location in locations)
            {
                umrdi = (UserMarkerRDI)umrdi.m_children[location];
                if (!umrdi.Displayed)
                {
                    return(null);
                }
            }

            umrdi = (UserMarkerRDI)umrdi.m_children[uml.GetNameForLogView(logView)];
            return(umrdi.Displayed ? umrdi : null);
        }
 public override bool Matches(UserMarkerLocation uml)
 {
     return(PathRegex.IsMatch(uml.m_path) && NameRegex.IsMatch(uml.m_name));
 }
 public virtual bool Matches(UserMarkerLocation uml)
 {
     return((uml.m_path == Path) && (uml.m_name == Name));
 }
示例#6
0
        static bool WriteXMLForLog(string logFilename, string[] groups)
        {
            FileLogProcessor logProcessor = new FileLogProcessor(logFilename);
            LogData          logData      = logProcessor.ProcessLog();

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = true;
            settings.IndentChars = ("    ");

            char[]   delims           = { '.' };
            string[] fileNameElements = logFilename.Split(delims);
            if (fileNameElements.Length < 2)
            {
                Console.WriteLine("Input file name not parseable {0} : Canceling XML Write", logFilename);
                return(false);
            }

            string outputFile = fileNameElements[0] + ".xml";

            Console.WriteLine("Writing XML output: {0}", outputFile);

            using (XmlWriter writer = XmlWriter.Create(outputFile, settings))
            {
                writer.WriteStartElement("testsuites");
                CultureInfo decimalCulture = new CultureInfo("en-US");

                UserMarkerLocation currentStartMarker = null;
                writer.WriteStartElement("testsuite");
                writer.WriteAttributeString("name", "BasicPerformance");

                foreach (FrameRecord fr in logData.FrameRecords)
                {
                    foreach (UserMarkerLocation markerLocation in fr.UserMarkers)
                    {
                        if (markerLocation.m_name.Split(' ')[0].EndsWith("_start"))
                        {
                            if (currentStartMarker != null)
                            {
                                //Warn about unmatched start marker
                                Console.WriteLine("Warning: Performance Marker End Not Found For {0} at frame index: {1} : Skipping", currentStartMarker.m_name, currentStartMarker.m_fr.Index);
                            }
                            currentStartMarker = markerLocation;
                            continue;
                        }

                        if (markerLocation.m_name.EndsWith("_end"))
                        {
                            if (currentStartMarker == null)
                            {
                                //Warn and skip if we didn't have a start marker we were looking for
                                Console.WriteLine("Warning: Performance Marker End Found With No Matching Start For {0} at frame index: {1} : Skipping", currentStartMarker != null ? currentStartMarker.m_name : "invalid start marker", currentStartMarker != null ? currentStartMarker.m_fr.Index : 0);
                                continue;
                            }

                            string markerNameStart  = currentStartMarker.m_name.Replace("_start", "").Split(' ')[0];
                            string markerExportName = currentStartMarker.m_name.Replace("_start", "");
                            string markerNameEnd    = markerLocation.m_name.Replace("_end", "");

                            if (markerNameStart != markerNameEnd)
                            {
                                Console.WriteLine("Warning: Performance Marker End: {0} Does not Match Start Marker {1}: Skipping", markerNameStart, markerNameEnd);
                                currentStartMarker = null;
                                continue;
                            }

                            int startIdx = currentStartMarker.m_fr.Index;
                            int endIdx   = markerLocation.m_fr.Index;
                            currentStartMarker = null;

                            writer.WriteStartElement("phase");
                            writer.WriteAttributeString("name", markerExportName);
                            writer.WriteAttributeString("duration", (logData.FrameRecords[endIdx].FrameTimeInS - logData.FrameRecords[startIdx].FrameTimeInS).ToString(decimalCulture));
                            {
                                float minFrameTime, maxFrameTime, avgFrameTime;
                                logData.GetFrameTimeData(startIdx, endIdx, out minFrameTime, out maxFrameTime, out avgFrameTime);

                                writer.WriteStartElement("metrics");
                                writer.WriteAttributeString("name", "frameTimes");

                                writer.WriteStartElement("metric");
                                writer.WriteAttributeString("name", "min");
                                writer.WriteAttributeString("value", minFrameTime.ToString(decimalCulture));
                                writer.WriteEndElement();

                                writer.WriteStartElement("metric");
                                writer.WriteAttributeString("name", "max");
                                writer.WriteAttributeString("value", maxFrameTime.ToString(decimalCulture));
                                writer.WriteEndElement();

                                writer.WriteStartElement("metric");
                                writer.WriteAttributeString("name", "avg");
                                writer.WriteAttributeString("value", avgFrameTime.ToString(decimalCulture));
                                writer.WriteEndElement();

                                writer.WriteEndElement();
                            }
                            writer.WriteEndElement();
                        }
                    }
                }
                //End testsuite block
                writer.WriteEndElement();

                if (groups != null)
                {
                    currentStartMarker = null;
                    writer.WriteStartElement("testsuite");
                    writer.WriteAttributeString("name", "GroupStatistics");

                    foreach (FrameRecord fr in logData.FrameRecords)
                    {
                        foreach (UserMarkerLocation markerLocation in fr.UserMarkers)
                        {
                            if (markerLocation.m_name.Split(' ')[0].EndsWith("_start"))
                            {
                                if (currentStartMarker != null)
                                {
                                    //Warn about unmatched start marker
                                    Console.WriteLine("Warning: Performance Marker End Not Found For {0} at frame index: {1} : Skipping", currentStartMarker.m_name, currentStartMarker.m_fr.Index);
                                }
                                currentStartMarker = markerLocation;
                                continue;
                            }

                            if (markerLocation.m_name.EndsWith("_end"))
                            {
                                if (currentStartMarker == null)
                                {
                                    //Warn and skip if we didn't have a start marker we were looking for
                                    Console.WriteLine("Warning: Performance Marker End Found With No Matching Start For {0} at frame index: {1} : Skipping", currentStartMarker != null ? currentStartMarker.m_name : "invalid start marker", currentStartMarker != null ? currentStartMarker.m_fr.Index : 0);
                                    continue;
                                }

                                string markerNameStart  = currentStartMarker.m_name.Replace("_start", "").Split(' ')[0];
                                string markerExportName = currentStartMarker.m_name.Replace("_start", "");
                                string markerNameEnd    = markerLocation.m_name.Replace("_end", "");

                                if (markerNameStart != markerNameEnd)
                                {
                                    Console.WriteLine("Warning: Performance Marker End: {0} Does not Match Start Marker {1}: Skipping", markerNameStart, markerNameEnd);
                                    currentStartMarker = null;
                                    continue;
                                }

                                int startIdx = currentStartMarker.m_fr.Index;
                                int endIdx   = markerLocation.m_fr.Index;
                                currentStartMarker = null;

                                writer.WriteStartElement("phase");
                                writer.WriteAttributeString("name", markerExportName);
                                writer.WriteAttributeString("duration", (logData.FrameRecords[endIdx].FrameTimeInS - logData.FrameRecords[startIdx].FrameTimeInS).ToString(decimalCulture));
                                {
                                    GroupsStats stats = new GroupsStats();
                                    logData.GetFrameGroupData(startIdx, endIdx, groups, stats);
                                    foreach (string group in stats.m_groupStats.Keys)
                                    {
                                        GroupItemStats groupsStats = stats.GetGroupItemsStats(group);
                                        foreach (string item in groupsStats.m_groupItemStats.Keys)
                                        {
                                            Stats itemStats = groupsStats.GetItemStats(item);
                                            writer.WriteStartElement("metrics");
                                            writer.WriteAttributeString("name", item);

                                            writer.WriteStartElement("metric");
                                            writer.WriteAttributeString("name", "min");
                                            writer.WriteAttributeString("value", itemStats.m_min.ToString(decimalCulture));
                                            writer.WriteEndElement();

                                            writer.WriteStartElement("metric");
                                            writer.WriteAttributeString("name", "max");
                                            writer.WriteAttributeString("value", itemStats.m_max.ToString(decimalCulture));
                                            writer.WriteEndElement();

                                            writer.WriteStartElement("metric");
                                            writer.WriteAttributeString("name", "avg");
                                            writer.WriteAttributeString("value", itemStats.m_avg.ToString(decimalCulture));
                                            writer.WriteEndElement();

                                            writer.WriteEndElement();
                                        }
                                    }
                                }
                                writer.WriteEndElement();
                            }
                        }
                    }
                    //End testsuite block
                    writer.WriteEndElement();
                }

                //End testsuites block
                writer.WriteEndElement();
                writer.Flush();

                return(true);
            }
        }