/// <summary> /// for CoreRT we can't use reflection to load type and run a method, so we simply generate a switch for all types.. /// </summary> private static string GetCoreRtSwitch(BuildPartition buildPartition) { if (!buildPartition.IsCoreRT) { return(default);
protected override string GetBuildArtifactsDirectoryPath(BuildPartition buildPartition, string programName) => useTempFolderForRestore ? Path.Combine(Path.GetTempPath(), programName) // store everything in temp to avoid collisions with IDE : base.GetBuildArtifactsDirectoryPath(buildPartition, programName);
internal static string Generate(BuildPartition buildPartition) { (bool useShadowCopy, string shadowCopyFolderPath) = GetShadowCopySettings(); var benchmarksCode = new List <string>(buildPartition.Benchmarks.Length); var extraDefines = new List <string>(); var targetTypeNamespaces = new HashSet <string>(); var targetMethodReturnTypeNamespace = new HashSet <string>(); var additionalLogic = new HashSet <string>(); foreach (var buildInfo in buildPartition.Benchmarks) { var benchmark = buildInfo.Benchmark; var provider = GetDeclarationsProvider(benchmark.Target); string passArguments = GetPassArguments(benchmark); extraDefines.Add($"{provider.ExtraDefines}_{buildInfo.Id}"); AddNonEmptyUnique(targetTypeNamespaces, provider.TargetTypeNamespace); AddNonEmptyUnique(targetMethodReturnTypeNamespace, provider.TargetMethodReturnTypeNamespace); AddNonEmptyUnique(additionalLogic, benchmark.Target.AdditionalLogic); string benchmarkTypeCode = new SmartStringBuilder(ResourceHelper.LoadTemplate("BenchmarkType.txt")) .Replace("$ID$", buildInfo.Id.ToString()) .Replace("$OperationsPerInvoke$", provider.OperationsPerInvoke) .Replace("$TargetTypeName$", provider.TargetTypeName) .Replace("$TargetMethodDelegate$", provider.TargetMethodDelegate) .Replace("$TargetMethodReturnType$", provider.TargetMethodReturnTypeName) .Replace("$IdleMethodReturnTypeName$", provider.IdleMethodReturnTypeName) .Replace("$GlobalSetupMethodName$", provider.GlobalSetupMethodName) .Replace("$GlobalCleanupMethodName$", provider.GlobalCleanupMethodName) .Replace("$IterationSetupMethodName$", provider.IterationSetupMethodName) .Replace("$IterationCleanupMethodName$", provider.IterationCleanupMethodName) .Replace("$IdleImplementation$", provider.IdleImplementation) .Replace("$ConsumeField$", provider.ConsumeField) .Replace("$JobSetDefinition$", GetJobsSetDefinition(benchmark)) .Replace("$ParamsContent$", GetParamsContent(benchmark)) .Replace("$ArgumentsDefinition$", GetArgumentsDefinition(benchmark)) .Replace("$DeclareArgumentFields$", GetDeclareArgumentFields(benchmark)) .Replace("$InitializeArgumentFields$", GetInitializeArgumentFields(benchmark)).Replace("$LoadArguments$", GetLoadArguments(benchmark)) .Replace("$PassArguments$", passArguments) .Replace("$EngineFactoryType$", GetEngineFactoryTypeName(benchmark)) .Replace("$Ref$", provider.UseRefKeyword ? "ref" : null) .Replace("$MeasureGcStats$", buildInfo.Config.HasMemoryDiagnoser() ? "true" : "false") .Replace("$DiassemblerEntryMethodName$", DisassemblerConstants.DiassemblerEntryMethodName) .Replace("$TargetMethodCall$", provider.GetTargetMethodCall(passArguments)).ToString(); benchmarkTypeCode = Unroll(benchmarkTypeCode, benchmark.Job.ResolveValue(RunMode.UnrollFactorCharacteristic, EnvResolver.Instance)); benchmarksCode.Add(benchmarkTypeCode); } if (buildPartition.IsCoreRT) { extraDefines.Add("#define CORERT"); } string benchmarkProgramContent = new SmartStringBuilder(ResourceHelper.LoadTemplate("BenchmarkProgram.txt")) .Replace("$ShadowCopyDefines$", useShadowCopy ? "#define SHADOWCOPY" : null).Replace("$ShadowCopyFolderPath$", shadowCopyFolderPath) .Replace("$ExtraDefines$", string.Join(Environment.NewLine, extraDefines)) .Replace("$TargetTypeNamespace$", string.Join(Environment.NewLine, targetTypeNamespaces)) .Replace("$TargetMethodReturnTypeNamespace$", string.Join(Environment.NewLine, targetMethodReturnTypeNamespace)) .Replace("$AdditionalLogic$", string.Join(Environment.NewLine, additionalLogic)) .Replace("$DerivedTypes$", string.Join(Environment.NewLine, benchmarksCode)) .Replace("$ExtraAttribute$", GetExtraAttributes(buildPartition.RepresentativeBenchmark.Target)) .Replace("$CoreRtSwitch$", GetCoreRtSwitch(buildPartition)) .ToString(); return(benchmarkProgramContent); }
internal static IEnumerable <string> GetAddPackagesCommands(BuildPartition buildPartition) => GetNuGetAddPackageCommands(buildPartition.RepresentativeBenchmarkCase, buildPartition.Resolver);