string printPretty(BenchmarkResult result)
        {
            var prettyBuilder = new StringBuilder();
            var rowFormat = "| {0,42}  | {1,25} |";
            var footerFormat = "  {0,42}    {1,25}  ";
            var header = String.Format(rowFormat, "URL", "Time (ms)");
            var separator = Enumerable.Range(1, 75).Select(i => "-").Aggregate((c, d) => c + d);

            prettyBuilder.AppendLine(separator);
            prettyBuilder.AppendLine(header);
            prettyBuilder.AppendLine(separator);
            var targets = result.AggregatedTimes.OrderByDescending(time => time.Key.Uri.AbsoluteUri);
            foreach (var target in targets)
            {
                var targetName = target.Key.Uri.AbsoluteUri;
                var targetResult = target.Value;

                var targetDisplayName = targetName.Length < 40 ?
                    targetName :
                    "..." + targetName.Substring(targetName.Length - 35);
                var targetDisplayResult = Math.Round(targetResult, 2);

                var line = String.Format(rowFormat, targetDisplayName, targetDisplayResult);
                prettyBuilder.AppendLine(line);
            }
            var totalDisplayResult = Math.Round(result.TotalTime, 2);
            var totalLine = String.Format(footerFormat, "Total:", totalDisplayResult);
            prettyBuilder.AppendLine(separator);
            prettyBuilder.AppendLine(totalLine);
            prettyBuilder.AppendLine();
            prettyBuilder.AppendLine();

            return prettyBuilder.ToString();
        }
Esempio n. 2
0
        static void benchmarkingRunFinished(IBenchmarkable sender, BenchmarkResult result)
        {
            ConsoleBuilder.AddResult(++FinishedRunCount, sender as RunBenchmark, result);
            if (CsvFilePath != String.Empty) CsvBuilder.AddResult(FinishedRunCount, sender as RunBenchmark, result);

            Console.WriteLine("Finished " + FinishedRunCount + "/" + TotalRunCount + " ...");

            if (FinishedRunCount >= TotalRunCount)
            {
                if (CsvFilePath != String.Empty)
                {
                    var csvContent = CsvBuilder.Build();
                    var exporter = new FileHelper();
                    try
                    {
                        exporter.Save(csvContent, CsvFilePath);
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Saving CSV failed. Do you have the required access privileges?");
                    }
                }

                Console.Write(ConsoleBuilder.Build());
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("Press any key to exit.");
            }
        }
        public override void AddResult(int number, RunBenchmark origin, BenchmarkResult result)
        {
            var runDelayTime = Math.Round(origin.AverageDelayTime).ToString();
            var runTerminalCount = origin.TerminalCount;
            var prettyResult = printPretty(result);

            ResultBuilder.AppendLine();
            ResultBuilder.AppendLine();
            ResultBuilder.AppendLine("Run " + number++ + " (n=" + runTerminalCount + ", t=" + runDelayTime + ") :");
            ResultBuilder.AppendLine(prettyResult);
        }
        public override void AddResult(int number, RunBenchmark origin, BenchmarkResult result)
        {
            var runDelayTime = Math.Round(origin.AverageDelayTime).ToString();
            var runTerminalCount = origin.TerminalCount;
            var targets = result.AggregatedTimes.OrderByDescending(time => time.Key.Uri.AbsoluteUri);
            var total = result.TotalTime;
            var totalDisplayResult = Math.Round(total, 2);

            ResultBuilder.AppendLine("Run " + number++ + " (n=" + runTerminalCount + ", t=" + runDelayTime + ") :");
            foreach (var target in targets)
            {
                var targetDisplayResult = Math.Round(target.Value, 2);
                ResultBuilder.AppendLine(target.Key.Uri.AbsoluteUri + _delimiter + targetDisplayResult);
            }

            ResultBuilder.AppendLine("Total: " + totalDisplayResult);
            ResultBuilder.AppendLine();
        }
Esempio n. 5
0
        void terminalFinished(object sender, BenchmarkResult partResult)
        {
            var senderTerminal = sender as TerminalBenchmark;
            var terminalTimes = partResult.AggregatedTimes;

            foreach (var times in terminalTimes)
            {
                if (_result.Times.ContainsKey(times.Key))
                {
                    _result.Times[times.Key].Add(times.Value);
                }
                else
                {
                    _result.Times[times.Key] = new List<double>() { times.Value };
                }
            }
            _terminals[senderTerminal] = true;

            if (_terminals.All(terminal => terminal.Value)) BenchmarkingFinished.Invoke(this, _result);
        }
Esempio n. 6
0
 void benchmarkingFinished(IBenchmarkable sender, BenchmarkResult result)
 {
     BenchmarkingFinished.Invoke(sender, result);
     if (_benchmarkableEnumerator.MoveNext()) benchmarkSingle(_benchmarkableEnumerator.Current);
 }
Esempio n. 7
0
 public TerminalBenchmark(int delayTime, IEnumerable<BenchmarkTarget> targets)
 {
     DelayTime = delayTime;
     Targets = targets;
     _results = new BenchmarkResult();
 }
Esempio n. 8
0
 public RunBenchmark(IEnumerable<TerminalBenchmark> terminals)
 {
     _terminals = terminals.ToDictionary(terminal => terminal, _ => false);
     _result = new BenchmarkResult();
 }
 public abstract void AddResult(int number, RunBenchmark origin, BenchmarkResult result);