private void ProcessLogLoadRequest(FileSessionInfo[] sessions)
        {
            using (ProfileSection p = new ProfileSection("Loading log"))

                try
                {
                    List <LogRange> logRanges           = new List <LogRange>();
                    TreeNode        sessionLogsBaseNode = null;

                    foreach (FileSessionInfo session in sessions)
                    {
                        Reset();

                        FileLogProcessor logProcessor = new FileLogProcessor(session);
                        LogData          logData      = logProcessor.ProcessLog();
                        LogRange         logRange     = new LogRange(logData, null);

                        logRanges.Add(logRange);
                        sessionLogsBaseNode = AddToLogRangeList(logRange);
                    }

                    int      numTabPages         = tabControl1.TabPages.Count;
                    string   tabName             = logRanges.Count == 1 ? logRanges[0].m_logData.Name : string.Format("{0} log compare", logRanges.Count);
                    TreeNode sessionTabsBaseNode = CreateLogControlTabPage(logRanges, tabName, null);

                    if (logRanges.Count == 1)
                    {
                        foreach (FrameRecordRange frr in logRanges[0].m_logData.LevelRanges)
                        {
                            List <LogRange> lrs      = new List <LogRange>();
                            LogRange        logRange = new LogRange(logRanges[0].m_logData, frr);

                            lrs.Add(logRange);
                            AddToLogRangeList(logRange, sessionLogsBaseNode, sessionTabsBaseNode);
                        }
                    }

                    SetSessionInfoList(logRanges[0]);

                    tabControl1.SelectTab(numTabPages);                 // select the newly opened page
                }
                catch (Exception e)
                {
                    System.Console.WriteLine(e);
                }
        }
Exemple #2
0
        static bool UploadConfluenceData(string settingsfile, string logfile, string[] groups, string platform, string buildid, string metrics, bool uploadSummary)
        {
            string username    = string.Empty;
            string password    = string.Empty;
            string space       = string.Empty;
            string parent      = string.Empty;
            string pagepostfix = string.Empty;

            try
            {
                StreamReader stream    = new StreamReader(settingsfile);
                XmlDocument  xmlDoc    = new XmlDocument();
                String       xmlstring = stream.ReadToEnd();
                stream.Close();
                xmlDoc.LoadXml(xmlstring);
                XmlNode settings = xmlDoc.SelectSingleNode("/settings");

                stream    = new StreamReader(metrics);
                xmlDoc    = new XmlDocument();
                xmlstring = stream.ReadToEnd();
                stream.Close();
                xmlDoc.LoadXml(xmlstring);
                XmlNodeList metricNodes = xmlDoc.SelectNodes("//metrics");

                foreach (XmlAttribute attrib in settings.Attributes)
                {
                    if (attrib.Name == "username")
                    {
                        username = attrib.Value;
                    }

                    if (attrib.Name == "password")
                    {
                        password = attrib.Value;
                    }

                    if (attrib.Name == "space")
                    {
                        space = attrib.Value;
                    }

                    if (attrib.Name == "parent")
                    {
                        parent = attrib.Value;
                    }

                    if (attrib.Name == "pageuniqueid")
                    {
                        pagepostfix = attrib.Value;
                    }
                }

                FileLogProcessor logProcessor = new FileLogProcessor(logfile);
                LogData          logData      = logProcessor.ProcessLog();

                if (platform == string.Empty)
                {
                    platform = logData.BuildInfo.PlatformString + " - Auto-testing Statistics - ";
                }

                if (buildid == string.Empty)
                {
                    buildid = logData.BuildInfo.BuildNumberString + " - Auto-testing Statistics - ";
                }

                platform += pagepostfix;
                buildid  += pagepostfix;

                ConfluenceService confluence = new ConfluenceService(logData);
                if (confluence.TryLogin(true, username, password))
                {
                    UploadStatsPages(confluence, logData, groups, space, parent, platform, buildid, metricNodes, uploadSummary, logfile);
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message + System.Environment.NewLine + "Stack: " + ex.StackTrace + System.Environment.NewLine);
                System.Environment.Exit(2);
            }
            return(true);
        }
Exemple #3
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);
            }
        }