Пример #1
0
        public BenchmarkResult Run()
        {
            var result = new BenchmarkResult(this.benchmark, this.container);

            if (!this.benchmark.IsSupportedBy(this.container))
            {
                return result;
            }

            this.benchmark.Warmup(this.container);

            result.SingleThreadedResult = this.singlethreadedMeasurer.Measure();

            if (result.SingleThreadedResult.Successful)
            {
                this.benchmark.Verify(this.container);
            }

            if ((this.benchmark.Threading | ThreadingCases.Multi) == this.benchmark.Threading)
            {
                this.benchmark.Warmup(this.container);
                
                result.MultiThreadedResult = this.multithreadedMeasurer.Measure();

                if (result.MultiThreadedResult.Successful)
                {
                    this.benchmark.Verify(this.container);
                }
            }

            return result;
        }
Пример #2
0
        public static IEnumerable<BenchmarkResult> GetExistingBenchmarkResults(
            IEnumerable<IBenchmark> currentBenchmarks,
            IEnumerable<IContainerAdapter> currentContainers)
        {
            if (!File.Exists("output\\result.xml"))
            {
                yield break;
            }

            XDocument doc = XDocument.Load("output\\result.xml");

            foreach (var container in currentContainers)
            {
                var containerElement = doc.Root
                    .Elements("Container")
                    .FirstOrDefault(c => c.Attribute("name").Value.Equals(container.Name)
                        && c.Attribute("version").Value.Equals(container.Version));

                if (containerElement == null)
                {
                    continue;
                }

                foreach (var benchmark in currentBenchmarks)
                {
                    var benchmarkElement = containerElement.Elements()
                        .FirstOrDefault(e => e.Attribute("type") != null && e.Attribute("type").Value.Equals(benchmark.GetType().FullName));

                    if (benchmarkElement == null)
                    {
                        continue;
                    }

                    var result = new BenchmarkResult(benchmark, container);

                    XElement singleThreadedResultElement = benchmarkElement.Element("SingleThreadedResult");
                    result.SingleThreadedResult = new Measurement()
                        {
                            Time = string.IsNullOrEmpty(singleThreadedResultElement.Attribute("time").Value) ? (long?)null : long.Parse(singleThreadedResultElement.Attribute("time").Value),
                            Error = singleThreadedResultElement.Attribute("error").Value,
                            ExtraPolated = bool.Parse(singleThreadedResultElement.Attribute("extrapolated").Value)
                        };

                    XElement multiThreadedResultElement = benchmarkElement.Element("MultiThreadedResult");
                    result.MultiThreadedResult = new Measurement()
                        {
                            Time = string.IsNullOrEmpty(multiThreadedResultElement.Attribute("time").Value) ? (long?)null : long.Parse(multiThreadedResultElement.Attribute("time").Value),
                            Error = multiThreadedResultElement.Attribute("error").Value,
                            ExtraPolated = bool.Parse(multiThreadedResultElement.Attribute("extrapolated").Value)
                        };

                    yield return result;
                }
            }
        }