Пример #1
0
        public static string GetLatencyStatSummariesReport(IEnumerable<CalcResult> results, Func<CalcResult, StatSummary> selector,
            AnalysisOptions options)
        {
            var res = new StringBuilder(DefaultBufferSize);

            if (options.SliceByNodeName)
                res.Append("NodeName\t");
            res.Append("Country\tCity\tLocation\tFunctionName");
            res.AppendLine("\tCount\tExceptionsCount\tAverage\tMin\tPercentile2\tLowerQuartile\tMedian\tUpperQuartile\tPercentile98\tMax");

            foreach (var result in results)
            {
                var summary = selector(result);
                if (summary == null)
                    continue;

                if (options.SliceByNodeName)
                    res.Append(result.NodeName);

                res.AppendFormat("{0}\t{1}\t{2}\t{3}", result.Country, result.City, result.Location, result.FunctionName);
                res.AppendLine("\t{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}",
                    summary.Count, result.ExceptionsCount, summary.Average,
                    summary.Min, summary.Percentile2, summary.LowerQuartile, summary.Median,
                    summary.UpperQuartile, summary.Percentile98, summary.Max);
            }

            return res.ToString();
        }
Пример #2
0
        private static void ProcessData(string resPath, string dataPath, TimeSpan period)
        {
            var sessions = LogReader.Parse(dataPath, TimePeriod.Create(period));
            sessions.AddRange(IisLogReader.ReadIisData(dataPath));

            var options = new AnalysisOptions
                {
                    LocationIncludeOverall = true
                };

            var convertor = new StatsBuilder();
            var res = convertor.Process(sessions, options);

            var summaryReport = Report.GetSummaryReport(sessions);
            File.WriteAllText(resPath + "\\Summary.txt", summaryReport, Encoding.UTF8);

            var statSummariesReport = Report.GetLatencyStatSummariesReport(res, options);
            File.WriteAllText(resPath + "\\LatencyStatSummaries.txt", statSummariesReport, Encoding.UTF8);

            var latencyDistributionReport = Report.GetLatencyDistributionReport(res);
            File.WriteAllText(resPath + "\\LatencyDistribution.txt", latencyDistributionReport, Encoding.UTF8);

            var jitterDsitributionReport = Report.GetJitterDistributionReport(res);
            File.WriteAllText(resPath + "\\JitterDistribution.txt", jitterDsitributionReport, Encoding.UTF8);
        }
Пример #3
0
        public void TestInternalValidation()
        {
            var dataPath = Util.GetAppLocation() + @"\Data\";
            var sessions = LogReader.Parse(dataPath, TimePeriod.Unlimited);
            Assert.IsTrue(sessions.Count > 0);

            var options = new AnalysisOptions { ApplicationKey = "CIAPI.CS.Excel" };
            var convertor = new StatsBuilder();
            var res = convertor.Process(sessions, options);
            Assert.IsTrue(res != null);

            var summaryReport = Report.GetSummaryReport(sessions);
            Assert.IsTrue(summaryReport != null);
        }
Пример #4
0
        public List<CalcResult> Process(List<SessionEx> sessions, AnalysisOptions options)
        {
            if (options == null)
                options = new AnalysisOptions();
            options.Validate();

            _options = options;
            _sessions = new List<SessionEx>(sessions);

            PrepareData();
            GC.Collect();

            var res = CalculateByCountries();
            return res;
        }
Пример #5
0
        public void TestReportsCorrectness()
        {
            var dataPath = Util.GetAppLocation() + @"\Data\";
            var sessions = LogReader.Parse(dataPath, TimePeriod.Unlimited);
            Assert.IsTrue(sessions.Count > 0);

            var options = new AnalysisOptions
                {
                    ApplicationKey = "CIAPI.CS.Excel",
                    LocationIncludeOverall = true,
                };
            var convertor = new StatsBuilder();
            var res = convertor.Process(sessions, options);
            Assert.IsTrue(res != null);

            var resultsPath = Util.GetAppLocation() + @"\Results\";

            {
                var summaryReport = Report.GetSummaryReport(sessions);
                var summarySample = File.ReadAllText(resultsPath + "TestData.Summary.txt");
                Assert.AreEqual(summaryReport, summarySample);
            }

            {
                var latencySummariesReport = Report.GetLatencyStatSummariesReport(res, options);
                var latencySummariesSample = File.ReadAllText(resultsPath + "TestData.LatencyStatSummaries.txt");
                Assert.AreEqual(latencySummariesSample, latencySummariesReport);
            }

            {
                var latencyDistributionReport = Report.GetLatencyDistributionReport(res);
                var latencyDistributionSample = File.ReadAllText(resultsPath + "TestData.LatencyDistribution.txt");
                Assert.AreEqual(latencyDistributionSample, latencyDistributionReport);
            }

            {
                var jitterDistributionReport = Report.GetJitterDistributionReport(res);
                var jitterDistributionSample = File.ReadAllText(resultsPath + "TestData.JitterDistribution.txt");
                Assert.AreEqual(jitterDistributionSample, jitterDistributionReport);
            }
        }
Пример #6
0
 public static string GetLatencyStatSummariesReport(IEnumerable<CalcResult> results, AnalysisOptions options)
 {
     return GetLatencyStatSummariesReport(results, calc => calc.StatSummary, options);
 }
Пример #7
0
        private static AnalysisOptions GetOptions(NameValueCollection requestParams)
        {
            var application = requestParams.Get("Application");
            if (application == null)
                throw new ApplicationException("Application key is not defined");

            var res = new AnalysisOptions
            {
                ApplicationKey = application,
            };

            var sliceByLocationText = requestParams.Get("SliceByLocation");
            res.SliceByLocation = string.IsNullOrEmpty(sliceByLocationText)
                ? LocationSliceType.None
                : (LocationSliceType)Enum.Parse(typeof(LocationSliceType), sliceByLocationText);

            var locations = requestParams.Get("Locations") ?? "";
            var locationList = locations.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            res.LocationIncludeOverall = (locationList.Length == 0);
            if (locationList.Contains("(World)"))
                res.LocationIncludeOverall = true;
            res.LocationFilter = new HashSet<string>(locationList);

            var functionFilter = requestParams.Get("FunctionFilter") ?? "";
            var functionFilterList = functionFilter.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            res.FunctionFilter = new HashSet<string>(functionFilterList);

            res.TimePeriod = TimePeriod.TryRead(requestParams);
            if (res.TimePeriod == null)
            {
                var periodString = requestParams.Get("Period") ?? "";
                var timeSpan = string.IsNullOrEmpty(periodString) ? DefaultReportPeriod : TimeSpan.Parse(periodString);
                res.TimePeriod = TimePeriod.Create(timeSpan);
            }

            var reportTypeText = requestParams.Get("Type");
            res.ReportType = string.IsNullOrEmpty(reportTypeText)
                ? ReportType.LatencySummaries
                : (ReportType)Enum.Parse(typeof(ReportType), reportTypeText);

            if (res.ReportType == ReportType.Exceptions)
            {
                res.SliceByFunction = false;
            }
            else
            {
                var splitByFunctionsText = (requestParams.Get("SliceByFunctions") ?? "").ToLower();
                res.SliceByFunction = (splitByFunctionsText == "yes");
            }

            var sliceByNodeNameText = (requestParams.Get("SliceByNodeName") ?? "").ToLower();
            res.SliceByNodeName = (sliceByNodeNameText == "yes");

            return res;
        }
Пример #8
0
        static List<CalcResult> CreateReport(AnalysisOptions options)
        {
            var sessions = LogReader.Parse(options);

            var convertor = new StatsBuilder();
            var res = convertor.Process(sessions, options);

            return res;
        }
Пример #9
0
 public static List<SessionEx> Parse(AnalysisOptions options)
 {
     var dataPath = SiteConfig.DataStoragePath + "\\" + options.ApplicationKey;
     return Parse(dataPath, options.TimePeriod);
 }