示例#1
0
        public async Task ShouldParseStatsFromCourseDetails(string domain, string filePath, ParkrunStats expectedStats)
        {
            using (var cancellationsPage = File.OpenRead(filePath))
            {
                var parser = new StatisticsParser();
                var stats  = await parser.Parse(cancellationsPage, domain);

                stats.Should().BeEquivalentTo(expectedStats);
            }
        }
示例#2
0
 public void StopCollector()
 {
     _timer.Stop();
     _timer.Dispose();
     StatisticsParser.Parse(
         _statisticsOutputPath,
         _percentileList,
         _latencyStep,
         _latencyMax,
         Log.Information);
 }
示例#3
0
        public static void ParseResult(string content)
        {
            var simpleModel    = new SimpleBenchmarkModel();
            var configData     = simpleModel.Deserialize(content);
            var percentileList = SignalRConstants.PERCENTILE_LIST.Split(",")
                                 .Select(ind => Convert.ToDouble(ind)).ToArray();

            StatisticsParser.Parse(
                configData.Config.ResultFilePath,
                percentileList,
                SignalRConstants.LATENCY_STEP,
                SignalRConstants.LATENCY_MAX,
                Log.Information);
        }
        protected BenchResult GetBenchResult(string output = null)
        {
            var resultFile = output != null ? output : SimpleBenchmarkModel.DEFAULT_OUTPUT_PATH;

            if (File.Exists(resultFile))
            {
                var percentileList = SignalRConstants.PERCENTILE_LIST.Split(",")
                                     .Select(ind => Convert.ToDouble(ind)).ToArray();
                var sb = new StringBuilder();
                StatisticsParser.Parse(
                    resultFile,
                    percentileList,
                    SignalRConstants.LATENCY_STEP,
                    SignalRConstants.LATENCY_MAX,
                    x => { sb.Append(x); },
                    true);
                var jsonResult = sb.ToString();
                _output.WriteLine(jsonResult);
                var benchResult = JsonConvert.DeserializeObject <BenchResult>(jsonResult);
                return(benchResult);
            }
            return(null);
        }
        private async Task <UpdateParkrunStatistics.Request> Run(Stream htmlStream, string path, CancellationToken cancellationToken)
        {
            var pathSplit     = path.Split('/');
            var websiteDomain = pathSplit[0];
            var websitePath   = '/' + pathSplit[1];

            _logger.LogInformation("Parsing parkrun statistics for {websiteDomain}{websitePath}", websiteDomain, websitePath);
            var statistics = await _parser.Parse(htmlStream, websiteDomain)
                             .ConfigureAwait(false);

            return(new UpdateParkrunStatistics.Request()
            {
                WebsiteDomain = websiteDomain,
                WebsitePath = websitePath,
                AverageRunnersPerWeek = statistics.AverageRunnersPerWeek,
                AverageSecondsRan = statistics.AverageSecondsRan,
                BiggestAttendance = statistics.BiggestAttendance,
                TotalEvents = statistics.TotalEvents,
                TotalKmDistanceRan = statistics.TotalKmDistanceRan,
                TotalRunners = statistics.TotalRunners,
                TotalRuns = statistics.TotalRuns,
                TotalSecondsRan = statistics.TotalSecondsRan
            });
        }