Exemplo n.º 1
0
 private static BenchmarkReport CreateReport(BenchmarkCase benchmarkCase, int n, double nanoseconds)
 {
     var buildResult  = BuildResult.Success(GenerateResult.Success(ArtifactsPaths.Empty, Array.Empty <string>()));
     var measurements = Enumerable.Range(0, n)
                        .Select(index => new Measurement(1, IterationMode.Workload, IterationStage.Result, index + 1, 1, nanoseconds + index).ToString())
                        .ToList();
     var executeResult = new ExecuteResult(true, 0, default, measurements, new[] { $"// Runtime=extra output line" }, 1);
Exemplo n.º 2
0
        private void Verify(string msbuildError, bool expectedResult, string expectedReason)
        {
            var sut = BuildResult.Failure(GenerateResult.Success(ArtifactsPaths.Empty, Array.Empty <string>()), msbuildError);

            Assert.Equal(expectedResult, sut.TryToExplainFailureReason(out string reason));
            Assert.Equal(expectedReason, reason);
        }
        public BuildResult Build(GenerateResult generateResult, BuildPartition buildPartition, ILogger logger)
        {
            Assembly  assembly   = null;
            Exception buildError = null;

            try
            {
                assembly = RunnableEmitter.EmitPartitionAssembly(generateResult, buildPartition, logger);
            }
            catch (Exception ex)
            {
                buildError = ex;
            }

            if (buildError != null)
            {
                return(BuildResult.Failure(generateResult, buildError));
            }

            // HACK: use custom artifacts path class to pass the generated assembly.
            return(BuildResult.Success(
                       GenerateResult.Success(
                           new InProcessEmitArtifactsPath(assembly, generateResult.ArtifactsPaths),
                           generateResult.ArtifactsToCleanup)));
        }
        public GenerateResult GenerateProject(Benchmark benchmark, ILogger logger, string rootArtifactsFolderPath, IConfig config, IResolver resolver)
        {
            if (!(benchmark is ExternalProcessBenchmark))
            {
                return(GenerateResult.Failure(null, Array.Empty <string>()));
            }

            return(GenerateResult.Success(_artifactsPaths, Array.Empty <string>()));
        }
Exemplo n.º 5
0
        private static BenchmarkReport CreateReport(BenchmarkCase benchmarkCase, int n, double nanoseconds)
        {
            var buildResult   = BuildResult.Success(GenerateResult.Success(ArtifactsPaths.Empty, Array.Empty <string>()));
            var executeResult = new ExecuteResult(true, 0, Array.Empty <string>(), Array.Empty <string>());
            var measurements  = Enumerable.Range(0, n)
                                .Select(index => new Measurement(1, IterationMode.Workload, IterationStage.Result, index + 1, 1, nanoseconds + index))
                                .ToList();

            return(new BenchmarkReport(true, benchmarkCase, buildResult, buildResult, new List <ExecuteResult> {
                executeResult
            }, measurements, default, Array.Empty <Metric>()));
Exemplo n.º 6
0
 private static BenchmarkReport CreateReport(BenchmarkCase benchmarkCase, int measurementValue, int noise)
 {
     var buildResult  = BuildResult.Success(GenerateResult.Success(ArtifactsPaths.Empty, Array.Empty <string>(), false));
     var measurements = new List <Measurement>
     {
         new Measurement(1, IterationMode.Workload, IterationStage.Result, 1, 1, measurementValue),
         new Measurement(1, IterationMode.Workload, IterationStage.Result, 2, 1, measurementValue + noise),
         new Measurement(1, IterationMode.Workload, IterationStage.Result, 3, 1, measurementValue - noise),
         new Measurement(1, IterationMode.Workload, IterationStage.Result, 4, 1, measurementValue + 2 * noise),
         new Measurement(1, IterationMode.Workload, IterationStage.Result, 5, 1, measurementValue - 3 * noise)
     };
     var executeResult = new ExecuteResult(measurements, default, default);
Exemplo n.º 7
0
        private static BenchmarkReport CreateReport(BenchmarkCase benchmarkCase, int n, double nanoseconds)
        {
            var buildResult   = BuildResult.Success(GenerateResult.Success(ArtifactsPaths.Empty, Array.Empty <string>()));
            var executeResult = new ExecuteResult(true, 0, 0, Array.Empty <string>(), new[] { $"// Runtime=extra output line" });
            var measurements  = Enumerable.Range(0, n)
                                .Select(index => new Measurement(1, IterationMode.Workload, IterationStage.Result, index + 1, 1, nanoseconds + index))
                                .ToList();
            var gcStats = GcStats.Parse("GC: 100 10 1 666666 888");

            return(new BenchmarkReport(true, benchmarkCase, buildResult, buildResult, new List <ExecuteResult> {
                executeResult
            }, measurements, gcStats, Array.Empty <Metric>()));
        }
Exemplo n.º 8
0
        private static BenchmarkReport CreateReport(Benchmark benchmark)
        {
            var buildResult   = BuildResult.Success(GenerateResult.Success(ArtifactsPaths.Empty));
            var executeResult = new ExecuteResult(true, 0, Array.Empty <string>(), Array.Empty <string>());
            var measurements  = new List <Measurement>
            {
                new Measurement(1, IterationMode.Result, 1, 1, 1)
            };

            return(new BenchmarkReport(benchmark, buildResult, buildResult, new List <ExecuteResult> {
                executeResult
            }, measurements, default(GcStats)));
        }
Exemplo n.º 9
0
        private static BenchmarkReport CreateReport(IConfig config)
        {
            var benchmark     = CreateBenchmark(config);
            var buildResult   = BuildResult.Success(GenerateResult.Success(ArtifactsPaths.Empty));
            var executeResult = new ExecuteResult(true, 0, new List <string>());
            var measurements  = new List <Measurement>
            {
                new Measurement(1, IterationMode.Result, 1, 1, 1)
            };

            return(new BenchmarkReport(benchmark, buildResult, buildResult, new List <ExecuteResult> {
                executeResult
            }, measurements));
        }
 private static BenchmarkReport CreateReport(BenchmarkCase benchmarkCase, bool hugeSd, Metric[] metrics)
 {
     var buildResult = BuildResult.Success(GenerateResult.Success(ArtifactsPaths.Empty, Array.Empty<string>()));
     var executeResult = new ExecuteResult(true, 0, Array.Empty<string>(), Array.Empty<string>());
     bool isFoo = benchmarkCase.Descriptor.WorkloadMethodDisplayInfo == "Foo";
     bool isBar = benchmarkCase.Descriptor.WorkloadMethodDisplayInfo == "Bar";            
     var measurements = new List<Measurement>
     {
         new Measurement(1, IterationMode.Workload, IterationStage.Result, 1, 1, 1),
         new Measurement(1, IterationMode.Workload, IterationStage.Result, 2, 1, hugeSd && isFoo ? 2 : 1),
         new Measurement(1, IterationMode.Workload, IterationStage.Result, 3, 1, hugeSd && isBar ? 3 : 1),
         new Measurement(1, IterationMode.Workload, IterationStage.Result, 4, 1, hugeSd && isFoo ? 2 : 1),
         new Measurement(1, IterationMode.Workload, IterationStage.Result, 5, 1, hugeSd && isBar ? 3 : 1),
         new Measurement(1, IterationMode.Workload, IterationStage.Result, 6, 1, 1)
     };
     return new BenchmarkReport(true, benchmarkCase, buildResult, buildResult, new List<ExecuteResult> { executeResult }, measurements, default, metrics);
Exemplo n.º 11
0
        private static BenchmarkReport CreateReport(BenchmarkCase benchmarkCase, int measurementValue)
        {
            var buildResult   = BuildResult.Success(GenerateResult.Success(ArtifactsPaths.Empty, Array.Empty <string>()));
            var executeResult = new ExecuteResult(true, 0, Array.Empty <string>(), Array.Empty <string>());
            var measurements  = new List <Measurement>
            {
                new Measurement(1, IterationMode.Workload, IterationStage.Result, 1, 1, measurementValue),
                new Measurement(1, IterationMode.Workload, IterationStage.Result, 2, 1, measurementValue),
                new Measurement(1, IterationMode.Workload, IterationStage.Result, 3, 1, measurementValue),
                new Measurement(1, IterationMode.Workload, IterationStage.Result, 4, 1, measurementValue),
                new Measurement(1, IterationMode.Workload, IterationStage.Result, 5, 1, measurementValue),
                new Measurement(1, IterationMode.Workload, IterationStage.Result, 6, 1, measurementValue),
            };

            return(new BenchmarkReport(true, benchmarkCase, buildResult, buildResult, new List <ExecuteResult> {
                executeResult
            }, measurements, default, Array.Empty <Metric>()));
Exemplo n.º 12
0
        public GenerateResult GenerateProject(
            BuildPartition buildPartition,
            ILogger logger,
            string rootArtifactsFolderPath)
        {
            var artifactsPaths = ArtifactsPaths.Empty;

            try
            {
                artifactsPaths = GetArtifactsPaths(buildPartition, rootArtifactsFolderPath);

                return(GenerateResult.Success(artifactsPaths, new List <string>()));
            }
            catch (Exception ex)
            {
                logger.WriteLineError($"Failed to generate partition: {ex}");
                return(GenerateResult.Failure(artifactsPaths, new List <string>()));
            }
        }
Exemplo n.º 13
0
        public GenerateResult GenerateProject(Benchmark benchmark, ILogger logger, string rootArtifactsFolderPath, IConfig config, IResolver resolver)
        {
            ArtifactsPaths artifactsPaths = null;

            try
            {
                artifactsPaths = GetArtifactsPaths(benchmark, config, rootArtifactsFolderPath);

                CopyAllRequiredFiles(benchmark, artifactsPaths);

                GenerateCode(benchmark, artifactsPaths);
                GenerateAppConfig(benchmark, artifactsPaths, resolver);
                GenerateProject(benchmark, artifactsPaths, resolver, logger);
                GenerateBuildScript(benchmark, artifactsPaths, resolver);

                return(GenerateResult.Success(artifactsPaths, GetArtifactsToCleanup(benchmark, artifactsPaths)));
            }
            catch (Exception ex)
            {
                return(GenerateResult.Failure(artifactsPaths, GetArtifactsToCleanup(benchmark, artifactsPaths), ex));
            }
        }
Exemplo n.º 14
0
        public GenerateResult GenerateProject(BuildPartition buildPartition, ILogger logger, string rootArtifactsFolderPath)
        {
            var artifactsPaths = ArtifactsPaths.Empty;

            try
            {
                artifactsPaths = GetArtifactsPaths(buildPartition, rootArtifactsFolderPath);

                CopyAllRequiredFiles(artifactsPaths);

                GenerateCode(buildPartition, artifactsPaths);
                GenerateAppConfig(buildPartition, artifactsPaths);
                GenerateNuGetConfig(artifactsPaths);
                GenerateProject(buildPartition, artifactsPaths, logger);
                GenerateBuildScript(buildPartition, artifactsPaths);

                return(GenerateResult.Success(artifactsPaths, GetArtifactsToCleanup(artifactsPaths)));
            }
            catch (Exception ex)
            {
                return(GenerateResult.Failure(artifactsPaths, GetArtifactsToCleanup(artifactsPaths), ex));
            }
        }
 /// <summary>returns a success</summary>
 public GenerateResult GenerateProject(BuildPartition buildPartition, ILogger logger, string rootArtifactsFolderPath)
 => GenerateResult.Success(null, Array.Empty <string>(), buildPartition.NoAcknowledgments);
Exemplo n.º 16
0
 private static BenchmarkReport CreateReport(BenchmarkCase benchmarkCase, int n, double nanoseconds)
 {
     var buildResult   = BuildResult.Success(GenerateResult.Success(ArtifactsPaths.Empty, Array.Empty <string>()));
     var executeResult = new ExecuteResult(true, 0, default, Array.Empty <string>(), new[] { $"// Runtime=extra output line" });
Exemplo n.º 17
0
 private static BenchmarkReport CreateReport(BenchmarkCase benchmarkCase, int measurementValue, int noise)
 {
     var buildResult   = BuildResult.Success(GenerateResult.Success(ArtifactsPaths.Empty, Array.Empty <string>()));
     var executeResult = new ExecuteResult(true, 0, default, Array.Empty <string>(), Array.Empty <string>());
Exemplo n.º 18
0
 /// <summary>Generates the project for benchmark.</summary>
 /// <param name="benchmark">The benchmark.</param>
 /// <param name="logger">The logger.</param>
 /// <param name="rootArtifactsFolderPath">The root artifacts folder path.</param>
 /// <param name="config">The config for benchmark.</param>
 /// <param name="resolver">The resolver.</param>
 /// <returns>Generation result.</returns>
 public GenerateResult GenerateProject(
     Benchmark benchmark, ILogger logger,
     string rootArtifactsFolderPath, IConfig config,
     IResolver resolver)
 => GenerateResult.Success(null, Array.Empty <string>());
 private static BenchmarkReport CreateReport(BenchmarkCase benchmarkCase, bool hugeSd, Metric[] metrics)
 {
     var  buildResult   = BuildResult.Success(GenerateResult.Success(ArtifactsPaths.Empty, Array.Empty <string>()));
     var  executeResult = new ExecuteResult(true, 0, default, Array.Empty <string>(), Array.Empty <string>());