private void OnUpdatedResult(BenchmarkResult result)
        {
            var typeSpecification = result.TypeSpecification;

            var eventArgs = new TestTargetUpdatedEventArgs(typeSpecification.AssemblyPath, typeSpecification.FullName);
            TestTargetUpdated.SafeInvoke(this, eventArgs);
        }
예제 #2
0
 public void OnUpdateResult(BenchmarkResult result)
 {
     var handler = UpdateResult;
     if (handler != null)
     {
         handler(result);
     }
 }
        public ResultsDataViewModel(BenchmarkResult benchmarkResult)
        {
            Argument.IsNotNull(() => benchmarkResult);

            Title = benchmarkResult.Key;
            BenchmarkResult = benchmarkResult;

            UpdateResults(BenchmarkResult);
        }
        private void UpdateResults(BenchmarkResult result)
        {
            if (!string.Equals(result.Key, BenchmarkResult.Key))
            {
                return;
            }

            DataTable = new BenchmarkFinalTabularData(result).DataTable;
        }
        public ResultsPlotViewModel(BenchmarkResult benchmarkResult, ISettings settings)
        {
            Argument.IsNotNull(() => benchmarkResult);
            Argument.IsNotNull(() => settings);

            BenchmarkResult = benchmarkResult;
            IsLogarithmicTimeAxisChecked = settings.IsLogarithmicTimeAxisChecked;
            UpdateResults(BenchmarkResult);
        }
예제 #6
0
        private BenchmarkResult GetBaseResult(BenchmarkResult newResult, Dictionary <string, BenchmarkResult> baseResults)
        {
            var key = newResult.Method + newResult.Graph;

            if (baseResults.ContainsKey(key))
            {
                return(baseResults[key]);
            }
            return(null);
        }
예제 #7
0
        async Task <BenchmarkResult> IMiner.StartBenchmark(CancellationToken stop, BenchmarkPerformanceType benchmarkType)
        {
            var bp = new BenchmarkResult {
                AlgorithmTypeSpeeds = new List <AlgorithmTypeSpeedPair> {
                    new AlgorithmTypeSpeedPair(AlgorithmType.ZHash, 12)
                }, Success = true
            };

            return(GetValueOrErrorSettings.GetValueOrError("StartBenchmark", bp));
        }
예제 #8
0
        private static Task PublishError(FileInfo processingFile, Exception error)
        {
            var errorResult = new BenchmarkResult
            {
                Success        = false,
                BaselineStderr = error.ToString()
            };

            return(PublishResult(processingFile, errorResult));
        }
예제 #9
0
        /// <summary>
        /// WaitBenchmarkResult returns <see cref="BenchmarkResult"/> after one of 3 conditions is fullfiled.
        /// Conditions are: Benchmark fails with error message, Benchmarks timeouts, Benchmark returns non-zero speed
        /// </summary>
        /// <param name="benchmarkProcess">Is the running <see cref="BenchmarkProcess"/></param>
        /// <param name="timeoutTime">Is the time after which we get timeout</param>
        /// <param name="delayTime">Is the delay time after which <paramref name="timeoutTime"/> starts counting</param>
        /// <param name="stop">Is the <see cref="CancellationToken"/> for stopping <paramref name="benchmarkProcess"/></param>
        public static async Task <BenchmarkResult> WaitBenchmarkResult(BenchmarkProcess benchmarkProcess, TimeSpan timeoutTime, TimeSpan delayTime, CancellationToken stop, CancellationToken stopAfterTicks)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            var timeoutTimerTime = timeoutTime + delayTime;

            using var timeoutSource = new CancellationTokenSource(timeoutTimerTime);
            BenchmarkResult ret     = null;
            var             timeout = timeoutSource.Token;

            using var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(timeout, stop, stopAfterTicks);
            try
            {
                await Task.Delay(delayTime, linkedCts.Token);

                ret = await benchmarkProcess.Execute(linkedCts.Token);
            }
            catch (OperationCanceledException)
            {
            }
            catch (Exception e)
            {
                Logger.Info("MinerToolkit", $"Error occured while waiting for benchmark result: {e.Message}");
                return(new BenchmarkResult {
                    ErrorMessage = e.Message
                });
            }

            // #1 if canceled return canceled
            if (stop.IsCancellationRequested)
            {
                Logger.Info("MinerToolkit", "Benchmark process was canceled by user");
                return(new BenchmarkResult {
                    ErrorMessage = "Cancelling per user request."
                });
            }
            if (ret == null)
            {
                return new BenchmarkResult {
                           ErrorMessage = "Benchmark result is null"
                }
            }
            ;
            if (ret.HasNonZeroSpeeds() || !string.IsNullOrEmpty(ret.ErrorMessage))
            {
                return(ret);
            }
            if (timeout.IsCancellationRequested)
            {
                Logger.Info("MinerToolkit", "Benchmark process timed out");
                return(new BenchmarkResult {
                    ErrorMessage = "Operation timed out."
                });
            }
            return(new BenchmarkResult());
        }
예제 #10
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);
                }
            }
        }
예제 #11
0
        /// <summary>
        /// Starts the benchmark.
        /// </summary>
        /// <param name="numberOfRepetitions">The number of repetitions.</param>
        public void StartBenchmark(int numberOfRepetitions)
        {
            this.memoryModelBenchmark = new MemoryModelBenchmark();

            var builder = selectMemoryModel().Builder();

            builder.Benchmark = this.memoryModelBenchmark;
            ModularMemoryModelFactories factories = builder.Build();

            MemoryModel = factories.MemoryModelSnapshotFactory;

            WatchFirstPhase   = new Stopwatch();
            WatchSecondPhase  = new Stopwatch();
            RepetitionCounter = 1;

            initialiseAnalysisSingletons();
            Watch = Stopwatch.StartNew();
            try
            {
                createControlFlowGraph();

                while (RepetitionCounter <= numberOfRepetitions)
                {
                    clearComputation();

                    BenchmarkResult result = new BenchmarkResult();
                    benchmarkResults.Add(result);
                    result.StartBenchmarking();

                    runFirstPhaseAnalysis();
                    runSecondPhaseAnalysis();

                    result.StopBenchmarking(this.memoryModelBenchmark);
                    this.memoryModelBenchmark.ClearResults();

                    RepetitionCounter++;
                }

                EndState = AnalysisEndState.Success;
            }
            catch (ThreadAbortException e)
            {
                EndState = (AnalysisEndState)e.ExceptionState;
            }
            catch (Exception e)
            {
                AnalysisException = e;
                EndState          = AnalysisEndState.Crash;
            }
            finally
            {
                Watch.Stop();
                IsFinished = true;
            }
        }
예제 #12
0
        public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
        {
            var result = new BenchmarkResult(this, container);

            if (container.SupportGeneric)
            {
                result.Time = base.Measure <ImportGeneric <int>, ImportGeneric <float>, ImportGeneric <object> >(container);
            }

            return(result);
        }
예제 #13
0
        public static async Task PutResult(ExperimentID expId, BenchmarkResult result, CloudQueue resultsQueue, CloudBlobContainer outputContainer)
        {
            var result2 = await PrepareBenchmarkResult(result, outputContainer);

            using (MemoryStream ms = new MemoryStream())
            {
                //ms.WriteByte(1);//signalling that this message contains a result
                (new BinaryFormatter()).Serialize(ms, result2);
                await resultsQueue.AddMessageAsync(new CloudQueueMessage(ms.ToArray()));
            }
        }
        public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
        {
            var result = new BenchmarkResult(this, container);

            if (container.SupportsConditional)
            {
                result.Time = base.Measure <ImportConditionObject1, ImportConditionObject2, ImportConditionObject3>(container);
            }

            return(result);
        }
        public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
        {
            var result = new BenchmarkResult(this, container);

            if (container.SupportsMultiple)
            {
                result.Time = base.Measure <ImportMultiple1, ImportMultiple2, ImportMultiple3>(container);
            }

            return(result);
        }
예제 #16
0
        public static void InsertProjects(ref BenchmarkResult br)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();

            addProjects(10000);

            watch.Stop();
            br.InsertProjectsElapsedMilliseconds = watch.ElapsedMilliseconds;
        }
예제 #17
0
        public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
        {
            var result = new BenchmarkResult(this, container);

            if (container.SupportsPropertyInjection)
            {
                result.Time = base.Measure <IComplexPropertyObject1, IComplexPropertyObject2, IComplexPropertyObject3>(container);
            }

            return(result);
        }
예제 #18
0
        public void FindBestFlattening()
        {
            BenchmarkResult best = BenchmarkResult.FindBest <BenchmarkResult[]>(new[]
            {
                new[] { SlowResult },
                new[] { FastResult },
                new[] { SlowResult }
            });

            Assert.AreEqual(FastResult, best);
        }
예제 #19
0
        protected override void RunBenchmark(BenchmarkResult bRes)
        {
            bRes.BeginLabel("10k simple prototypes load");

            this.parser.Parse(this.xml, "TEST", new PrototypeParseParameters()
            {
                standardNamespace = "UnityTK.Editor.Benchmarking"
            });

            bRes.EndLabel();
        }
        public ComparableResult(BenchmarkResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }
            this.result = result;

            sat     = int.Parse(result.Properties[Z3Domain.KeySat], CultureInfo.InvariantCulture);
            unsat   = int.Parse(result.Properties[Z3Domain.KeyUnsat], CultureInfo.InvariantCulture);
            unknown = int.Parse(result.Properties[Z3Domain.KeyUnknown], CultureInfo.InvariantCulture);
        }
예제 #21
0
        /// <summary>
        /// Run a pattern scan benchmark.
        /// </summary>
        /// <param name="patternScanAlgorithm">The PatternScanAlgorithm to test.</param>
        /// <param name="memoryPatterns">A list of MemoryPatterns to look for.</param>
        /// <param name="moduleMemory">The memory to scan for the patterns.</param>
        /// <returns>A benchmark result.</returns>
        internal static async Task <BenchmarkResult> RunBenchmark(KeyValuePair <string, PatternScanAlgorithm> patternScanAlgorithm, List <MemoryPattern> memoryPatterns, byte[] moduleMemory)
        {
            await Task.Delay(100);  // give thread some time to initialize

            BenchmarkResult benchmarkResult = new BenchmarkResult
            {
                success = false,
                timings = new long[ITERATIONS]
            };
            bool algoSuccess = true;

            Stopwatch stopWatch = new Stopwatch();

            GC.KeepAlive(stopWatch);
            stopWatch.Start();
            benchmarkResult.message = patternScanAlgorithm.Value.Init(in moduleMemory);
            stopWatch.Stop();
            for (int run = 0; run < ITERATIONS; run++)
            {
                GC.Collect();
                if (GC.WaitForFullGCComplete() != GCNotificationStatus.Succeeded)
                {
                    await Task.Delay(100);
                }
                GC.WaitForPendingFinalizers();
                if (run == 0)
                {
                    stopWatch.Start();
                }
                else
                {
                    stopWatch.Restart();
                }
                foreach (MemoryPattern memoryPattern in memoryPatterns)
                {
                    if (patternScanAlgorithm.Value.FindPattern(in moduleMemory, in memoryPattern.CbPattern, memoryPattern.SzMask) == memoryPattern.ExpectedAddress)
                    {
                        continue;
                    }
                    algoSuccess = false;
                    break;
                }
                stopWatch.Stop();
                if (!algoSuccess)
                {
                    return(benchmarkResult);
                }
                benchmarkResult.timings[run] = (long)(stopWatch.ElapsedTicks / (double)Stopwatch.Frequency * 1000.0);
            }

            benchmarkResult.success = true;
            return(benchmarkResult);
        }
예제 #22
0
        public void Benchmark_RandomText()
        {
            string text = generator.RandomText();
            string word = generator.Word(text);

            BenchmarkResult result = BenchmarkQuery(string.Format("content: {0}*", word));

            Assert.That(result,
                        Has.Property("Count").GreaterThan(0)
                        & Has.Property("AverageDelay").LessThan(500)
                        & Has.Property("CountPass").True, "Search for '" + word + "' from '" + text + "' failed");
        }
예제 #23
0
 private static string DisplayResultSuiteToString(ResultSuite suite, ResultColumns columns, BenchmarkResult standardForScore)
 {
     using (MemoryStream stream = new MemoryStream())
     using (StreamWriter writer = new StreamWriter(stream))
     using (StreamReader reader = new StreamReader(stream))
     {
         suite.Display(writer, columns, standardForScore);
         writer.Flush();
         stream.Position = 0;
         return reader.ReadToEnd();
     }
 }
예제 #24
0
        // Create n blogs with m comments each.
        public async Task <Benchmark> BenchmarkCreatingBlogs()
        {
            var benchmark             = new Benchmark(BenchmarkType.CreateAllBlogs);
            var blogGenerationResults = this._blogGenerator.GenerateBlogsWithComments();

            var blogCount = 1;

            foreach (var result in blogGenerationResults)
            {
                var benchmarkResult = new BenchmarkResult {
                    BlogGenerationResult = result
                };

                var newBlog = new Blog
                {
                    Id           = Guid.NewGuid().ToString(),
                    BlogType     = result.BlogType,
                    Content      = result.BlogText,
                    Title        = Constants.BlogTitlePrefix + " " + blogCount % 2,
                    Name         = Constants.BlogNamePrefix + " " + blogCount % 2,
                    CreatedOn    = DateTime.UtcNow,
                    BlogComments = result.Comments.Select(generatedComment => new Comment
                    {
                        AuthorName  = TextHelper.GetRandomName(),
                        CommentedOn = DateTime.UtcNow,
                        CommentText = generatedComment
                    }).ToList()
                };

                if (result.BlogType == BlogType.Embedded)
                {
                    newBlog.Type = Constants.EmbeddedBlogTypeKey;
                    benchmarkResult.EmbeddedBlogResponse = await this._embeddedOperations.CreateBlog(newBlog.CastTo <EmbeddedBlog>());
                }
                else
                {
                    newBlog.Type = Constants.BlogTypeKey;
                    var createBlogResult = await this._referentialOperations.CreateBlog(newBlog.CastTo <ReferentialBlog>());

                    benchmarkResult.ReferentialBlogResponse = createBlogResult.Item1;
                    benchmarkResult.ChildBenchmarkResults   = createBlogResult.Item2.Select(c => new BenchmarkResult {
                        ReferentialCommentResponse = c
                    }).ToList();
                }

                benchmark.BenchmarkResults.Add(benchmarkResult);

                blogCount++;
            }

            return(benchmark);
        }
 public void Create(BenchmarkResult benchmarkResult)
 {
     try
     {
         var model = MapEntity(benchmarkResult);
         model.CreateDateTime = DateTime.Now;
         var id = Connection.Insert<BenchmarkResultEntity>(model);
     }
     catch (Exception ex)
     {
         return;
     }
 }
예제 #26
0
        protected override void RunBenchmark(BenchmarkResult bRes)
        {
            bRes.BeginLabel("10k simple prototypes load");

            this.parser.Parse(this.xml, "TEST");

            foreach (var error in this.parser.GetParsingErrors())
            {
                error.DoUnityDebugLog();
            }

            bRes.EndLabel();
        }
예제 #27
0
 public BenchmarkResult Run(int i)
 {
     try
     {
         BenchmarkResult result = _benchmarkService.Run(i);
         WriteResult(result);
         return(result);
     }
     catch (BenchmarkException ex)
     {
         throw new Exception(ex.Message, ex);
     }
 }
        public void BenchmarkResult_is_correct()
        {
            int             i = 0;
            BenchmarkResult r = CK.Core.MicroBenchmark.MeasureTime(() => ++ i);

            r.Average.Should().Be(r.Timings.Average());
            r.MaxTiming.Should().Be(r.Timings.Max());
            r.MinTiming.Should().Be(r.Timings.Min());
            r.StandardDeviation.Should().Be(Math.Sqrt(r.Timings.Average(z => z * z) - Math.Pow(r.Timings.Average(), 2)));
            r.MeanAbsoluteDeviation.Should().Be(r.Timings.Select(t => Math.Abs(t - r.Timings.Average())).Sum() / r.Timings.Count);
            r.NormalizedMean.Should().Be(r.Timings.Where(t => t < r.Average + r.MeanAbsoluteDeviation).Sum() / r.Timings.Where(t => t < r.Average + r.MeanAbsoluteDeviation).Count());
            i.Should().Be(1 + 5 * 10000);
        }
        public void Benchmarking_timed_operations()
        {
            int Fib(int n)
            {
                return(n <= 0 ? n : Fib(n - 1) + Fib(n - 2));
            }

            BenchmarkResult r1 = CK.Core.MicroBenchmark.MeasureTime(() => Fib(10));
            BenchmarkResult r2 = CK.Core.MicroBenchmark.MeasureTime(() => Fib(11));

            r1.IsBetterThan(r2).Should().BeTrue();
            r1.IsSignificantlyBetterThan(r2).Should().BeTrue();
            r1.IsTotallyBetterThan(r2).Should().BeTrue();
        }
        private void GenerateSingleResult(StringBuilder builder)
        {
            if (_results.All.Count == 0)
            {
                return;
            }
            BenchmarkResult result = _results.All[0];

            builder.Append("Benchmarking Results:");
            builder.Append(NewLine);
            if (_configuration.MeasurementType == MeasurementType.Peak)
            {
                builder.Append("  Measurement Type: Peak performance");
            }
            else
            {
                builder.Append($"  Measurement Type: Nominal rate at {_configuration.NominalRate} tps");
            }
            builder.Append(NewLine);

            builder.Append($"  Start Time:   {result.StartTime.ToLongTimeString()}");
            builder.Append(NewLine);
            DateTime endTime = result.StartTime.Add(result.ElapsedTime);

            builder.Append($"  End Time:     {endTime.ToLongTimeString()}");
            builder.Append(NewLine);
            builder.Append($"  Elapsed Time: {result.ElapsedTime.ToString()}");
            builder.Append(NewLine);
            builder.Append($"  Min Performance (tps):     {result.PerformanceMeasurement.MinValue:0.##}");
            builder.Append(NewLine);
            builder.Append(
                $"  Average Performance (tps): {result.PerformanceMeasurement.AverageValue:0.##}");
            builder.Append(NewLine);
            builder.Append($"  Max Performance (tps):     {result.PerformanceMeasurement.MaxValue:0.##}");
            builder.Append(NewLine);
            builder.Append($"  Min CPU Load (%):          {result.CpuLoadMeasurement.MinValue:0.##}");
            builder.Append(NewLine);
            builder.Append($"  Average CPU Load (%):      {result.CpuLoadMeasurement.AverageValue:0.##}");
            builder.Append(NewLine);
            builder.Append($"  Max CPU Load (%):          {result.CpuLoadMeasurement.MaxValue:0.##}");
            builder.Append(NewLine);
            builder.Append($"  Min Memory Usage (Mb):     {result.MemoryUsageMeasurement.MinValue:0.##}");
            builder.Append(NewLine);
            builder.Append(
                $"  Average Memory Usage (Mb): {result.MemoryUsageMeasurement.AverageValue:0.##}");
            builder.Append(NewLine);
            builder.Append($"  Max Memory Usage (Mb):     {result.MemoryUsageMeasurement.MaxValue:0.##}");
            builder.Append(NewLine);
            builder.Append(NewLine);
        }
예제 #31
0
        public override BenchmarkResult DoBenchmark()
        {
            BenchmarkResult result = new BenchmarkResult();

            base.WriteMessage("== Starting GPU Benchmark ==\r\n");
            result.StepsDetails.Add("Starting GPU Benchmark");

            result.StartedAt = DateTime.Now;

            result.FinishedAt = DateTime.Now;
            base.WriteMessage("== Finished GPU Benchmark ==\r\n\r\n");
            result.StepsDetails.Add("Finished GPU Benchmark");
            return(result);
        }
        public void Benchmarking_CPU_is_less_precise_that_time()
        {
            int Fib(int n)
            {
                return(n <= 0 ? n : Fib(n - 1) + Fib(n - 2));
            }

            BenchmarkResult r1 = CK.Core.MicroBenchmark.MeasureCPU(() => Fib(10));
            BenchmarkResult r2 = CK.Core.MicroBenchmark.MeasureCPU(() => Fib(15));

            r1.IsBetterThan(r2).Should().BeTrue();
            r1.IsSignificantlyBetterThan(r2).Should().BeTrue();
            r1.IsTotallyBetterThan(r2).Should().BeTrue();
        }
예제 #33
0
        private BenchmarkResult BenchmarkQuery(string query, int take = 10, int skip = 0)
        {
            BenchmarkResult result = new BenchmarkResult();

            for (int i = 0; i < 10; i++)
            {
                Stopwatch     timer = Stopwatch.StartNew();
                ISearchResult test  = index.Search(query).Take(take).Skip(skip);
                test.ToList();
                timer.Stop();
                result.Record(timer.ElapsedMilliseconds, test.TotalCount);
            }
            return(result);
        }
예제 #34
0
        public void TestConstructionTime()
        {
            Console.WriteLine("-- construction time");
            foreach (var cls in benchmarkClasses)
            {
                BenchmarkResult result = Measure(new CallableIntHelper(this, cls).Call);

                Console.WriteLine(
                    string.Format(CultureInfo.InvariantCulture, "{0,15}s input: {1}, time[ms]: {2}" /*"%-15s input: %d, time[ms]: %s"*/,
                                  cls.Name,
                                  dictionaryInput.Length,
                                  result.average.ToString()));
            }
        }
        /// <summary>
        /// Print benchmark result to console
        /// </summary>
        /// <param name="result"></param>
        public void OnResult(BenchmarkResult result)
        {
            var executorName = result.Executor.GetType().Name;

            if (executorName.EndsWith(AttributeSuffix))
            {
                executorName = executorName.Substring(0, executorName.Length - AttributeSuffix.Length);
            }
            var methodFullName   = $"{result.Method.DeclaringType.Name}.{result.Method.Name}";
            var elapsedSeconds   = result.Elapsed.TotalSeconds;
            var collectionCounts = string.Join(", ", result.CollectionCounts);

            Console.WriteLine($"({executorName}) {methodFullName}: {elapsedSeconds}s, GC: [{collectionCounts}]");
        }
예제 #36
0
        static Task <double> RunReference(string[] args)
        {
#if DEBUG
            string workerDir = @"C:\temp\azworker-tmp";
#else
            string workerDir = Path.Combine(Environment.GetEnvironmentVariable(SharedDirEnvVariableName), Environment.GetEnvironmentVariable(JobIdEnvVariableName));
#endif
            string normalFilePath = Path.Combine(workerDir, PerformanceCoefficientFileName);
            string refJsonPath    = Path.Combine(workerDir, "reference.json");
            if (!File.Exists(refJsonPath))
            {
                //no reference experiment
                Trace.WriteLine("Reference.json not found, assuming normal 1.0.");
                File.WriteAllText(normalFilePath, "1.0");
                return(Task.FromResult(1.0));
            }
            var exp = ParseReferenceExperiment(refJsonPath);

            var pathForBenchmarks = Path.Combine(workerDir, "refdata", "data");
            var execPath          = Path.Combine(workerDir, "refdata", exp.Definition.Executable);

            Domain   domain     = ResolveDomain(exp.Definition.DomainName);
            string[] benchmarks = Directory.EnumerateFiles(pathForBenchmarks).Select(fn => Path.Combine(pathForBenchmarks, fn)).ToArray();
            Trace.WriteLine(string.Format("Found {0} benchmarks in folder {1}", benchmarks.Length, pathForBenchmarks));
            BenchmarkResult[] results = new BenchmarkResult[benchmarks.Length];
            for (int i = 0; i < benchmarks.Length; ++i)
            {
                Trace.WriteLine(string.Format("Procssing reference file {0}", benchmarks[i]));
                results[i] = LocalExperimentRunner.RunBenchmark(
                    -1,
                    execPath,
                    exp.Definition.Parameters,
                    "ref",
                    benchmarks[i],
                    exp.Repetitions,
                    exp.Definition.BenchmarkTimeout,
                    exp.Definition.MemoryLimitMB,
                    null,
                    null,
                    domain,
                    1.0);
            }

            var    totalRuntime = results.Sum(r => r.NormalizedCPUTime);
            double normal       = exp.ReferenceValue / totalRuntime;

            File.WriteAllText(normalFilePath, normal.ToString());
            return(Task.FromResult(normal));
        }
        public static void UpdateResults(this BenchmarkResult benchmarkResult, BenchmarkResult newResult)
        {
            Argument.IsNotNull(() => benchmarkResult);
            Argument.IsNotNull(() => newResult);

            benchmarkResult.Key = newResult.Key;
            benchmarkResult.TestCases = newResult.TestCases;

            foreach (var result in newResult.Values)
            {
                var groupedValues = new List<KeyValuePair<string, double>>();
                var existingValues = new HashSet<string>();

                // 1) Create new values
                foreach (var value in result.Value)
                {
                    existingValues.Add(value.Key);
                    groupedValues.Add(new KeyValuePair<string, double>(value.Key, value.Value));
                }

                // 2) Copy existing values
                if (benchmarkResult.Values.ContainsKey(result.Key))
                {
                    var existingGroupedValues = benchmarkResult.Values[result.Key];
                    foreach (var value in existingGroupedValues)
                    {
                        if (!existingValues.Contains(value.Key))
                        {
                            existingValues.Add(value.Key);
                            groupedValues.Add(new KeyValuePair<string, double>(value.Key, value.Value));
                        }
                    }
                }

                benchmarkResult.Values[result.Key] = groupedValues;
            }

            benchmarkResult.RaiseUpdated();
        }
        public BenchmarkFinalTabularData(BenchmarkResult result)
        {
            Argument.IsNotNull(() => result);

            Title = result.Key;
            var table = new DataTable(Title);

            table.Columns.Add(DescriptionColumnName, typeof (string));

            foreach (var value in result.Values)
            {
                foreach (var dataPoint in value.Value)
                {
                    var dataPointColumnName = GetColumnName(dataPoint.Key);
                    if (!table.Columns.Contains(dataPointColumnName))
                    {
                        table.Columns.Add(dataPointColumnName, typeof (double));
                    }
                }
            }

            foreach (var series in result.Values)
            {
                var row = table.NewRow();
                table.Rows.Add(row);
                row[DescriptionColumnName] = series.Key;

                foreach (var dataPoint in series.Value)
                {
                    var columnName = GetColumnName(dataPoint.Key);
                    row[columnName] = dataPoint.Value;
                }
            }

            DataTable = table;
        }
예제 #39
0
 /// <summary>
 /// Method to invoke when the CloseBenchmarkResult command is executed.
 /// </summary>
 private void OnCloseBenchmarkResultExecute(BenchmarkResult result)
 {
     BenchmarkResults.Remove(result);
 }
예제 #40
0
        private void OnUpdateResult(BenchmarkResult result)
        {
            var currentItem = (from x in BenchmarkResults
                               where string.Equals(x.Key, result.Key)
                               select x).FirstOrDefault();
            if (currentItem != null)
            {
                currentItem.UpdateResults(result);
                return;
            }

            BenchmarkResults.Add(result);

            if (SelectedBenchmarkResult == null)
            {
                SelectedBenchmarkResult = result;
            }
        }
예제 #41
0
        private void OnUpdateResult(BenchmarkResult benchmark)
        {
            var typeSpecification = benchmark.TypeSpecification;
            if (typeSpecification == null)
            {
                Log.Warning("Benchmark.TypeSpecification is null, cannot dynamically load assembly information");
                return;
            }

            AddAssembly(typeSpecification.AssemblyPath);

            SelectSpecificTypes(typeSpecification.FullName);
        }
예제 #42
0
 internal BenchmarkPair(BenchmarkResult left, BenchmarkResult right)
 {
     this.Left = left;
     this.Right = right;
 }
        private void UpdateResults(BenchmarkResult result = null)
        {
            if (result == null)
            {
                result = BenchmarkResult;
            }
            if (!string.Equals(result.Key, BenchmarkResult.Key))
            {
                return;
            }

            int dummy;
            PlotModel = int.TryParse(result.TestCases.FirstOrDefault(), out dummy)
                ? Benchmarker.CreatePlotModel(result, !IsLogarithmicTimeAxisChecked)
                : Benchmarker.CreateCategoryPlotModel(result, !IsLogarithmicTimeAxisChecked);
        }
예제 #44
0
파일: Program.cs 프로젝트: slorion/nlight
		static void OutputResults(object sender, BenchmarkOptions benchmarkOptions, RecordReaderBenchmarkArguments benchmarkArgs, long iterationIndex, BenchmarkResult result)
		{
			var fi = new System.IO.FileInfo(benchmarkArgs.Path);
			decimal rate = ((decimal) fi.Length / 1024 / 1024) / ((decimal) result.Timer.ElapsedMilliseconds / 1000);

			Console.WriteLine("{0}: {1,25}: {2,10} ticks, {3,10} bytes, {4,4} gc0, {5,4} gc1, {6,4} gc2, {7,6:F} MB/s", iterationIndex, result.Name, result.Timer.ElapsedTicks, result.UsedMemory, result.GC0, result.GC1, result.GC2, rate);
			Trace.WriteLine(string.Format("{0},{1},{2},{3},{4},{5},{6},{7:F}", iterationIndex, result.Name, result.Timer.ElapsedTicks, result.UsedMemory, result.GC0, result.GC1, result.GC2, rate));
		}
        public ResultsViewModel(BenchmarkResult benchmarkResult)
        {
            Argument.IsNotNull(() => benchmarkResult);

            BenchmarkResult = benchmarkResult;
        }
예제 #46
0
 public void UpdateResult(BenchmarkResult result)
 {
     var host = _dependencyResolver.Resolve<IUIServiceHost>();
     host.OnUpdateResult(result);
 }