private void TestProjectFromPerfTestSourceRepository( ProjectPerfOperation operation, string testName, string solutionDirectoryNameInPerfTestRepo, string projectDirectoryName = null) { string sourceProject = Path.Combine( TestContext.GetRepoRoot(), $".perftestsource/PerformanceTestProjects/{solutionDirectoryNameInPerfTestRepo}"); var testDir = _testAssetsManager.CreateTestDirectory( solutionDirectoryNameInPerfTestRepo, identifier: operation.ToString()); Console.WriteLine($"Mirroring {sourceProject} to {testDir}..."); FolderSnapshot.MirrorFiles(sourceProject, testDir.Path); TestContext.Current.WriteGlobalJson(testDir.Path); Console.WriteLine("Done"); string projectFolderOrFile = projectDirectoryName != null ? Path.Combine(testDir.Path, projectDirectoryName) : testDir.Path; TestProject(projectFolderOrFile, testName, operation); }
public void BuildProjectFromPerfSuite(string name, ProjectPerfOperation operation) { string sourceProject = Path.Combine(@"C:\MSBPerf\3", name); var testDir = _testAssetsManager.CreateTestDirectory("Perf_" + name, identifier: operation.ToString()); FolderSnapshot.MirrorFiles(sourceProject, testDir.Path); // The generated projects target .NET Core 2.1, retarget them to .NET Core 2.0 foreach (var projFile in Directory.GetFiles(testDir.Path, "*.csproj", SearchOption.AllDirectories)) { var project = XDocument.Load(projFile); var ns = project.Root.Name.Namespace; // Find both TargetFramework and TargetFrameworks elements var targetFrameworkElements = project.Root.Elements(ns + "PropertyGroup").Elements("TargetFramework"); targetFrameworkElements = targetFrameworkElements.Concat(project.Root.Elements(ns + "PropertyGroup").Elements("TargetFrameworks")); foreach (var tfElement in targetFrameworkElements) { tfElement.Value = tfElement.Value.Replace("netcoreapp2.1", "netcoreapp2.0"); } project.Save(projFile); } TestProject(testDir.Path, name, operation); }
public void BuildRoslynCompilers(ProjectPerfOperation operation) { string sourceProject = @"C:\git\roslyn"; var testDir = _testAssetsManager.CreateTestDirectory("Perf_Roslyn", identifier: operation.ToString()); Console.WriteLine($"Mirroring {sourceProject} to {testDir.Path}..."); FolderSnapshot.MirrorFiles(sourceProject, testDir.Path); TestContext.Current.WriteGlobalJson(testDir.Path); Console.WriteLine("Done"); // Override global.json from repo File.Delete(Path.Combine(testDir.Path, "global.json")); // Run Roslyn's restore script var restoreCmd = new SdkCommandSpec() { FileName = Path.Combine(testDir.Path, "Restore.cmd"), WorkingDirectory = testDir.Path }; TestContext.Current.AddTestEnvironmentVariables(restoreCmd); restoreCmd.ToCommand().Execute().Should().Pass(); TestProject(Path.Combine(testDir.Path, "Compilers.sln"), "Roslyn", operation); }
public void BuildNetFullFrameworkWindowsFormsLarge(ProjectPerfOperation operation) { TestProjectFromPerfTestSourceRepository( operation: operation, testName: "Build Full framework Windows Forms large", solutionDirectoryNameInPerfTestRepo: "WinformsNetFrameworkPerfApp1"); }
public void BuildNetFullFrameworkWindowsFormsHelloWorld(ProjectPerfOperation operation) { var testAsset = _testAssetsManager .CopyTestAsset("WindowsFormsHelloWorldFullFramework", identifier: operation.ToString()) .WithSource(); TestProject(testAsset.Path, "Full Windows Forms hello world", operation); }
public void BuildWebLarge30(ProjectPerfOperation operation) { TestProjectFromPerfTestSourceRepository( operation: operation, testName: "Build Web Large 3.0", solutionDirectoryNameInPerfTestRepo: "WebLarge30", projectDirectoryName: "mvc"); }
public void BuildNetFullFrameworkWpfLarge(ProjectPerfOperation operation) { TestProjectFromPerfTestSourceRepository( operation: operation, testName: "Build Full framework WPF large", solutionDirectoryNameInPerfTestRepo: "WpfLargeFullframework", projectDirectoryName: "WpfLargeFullframework"); }
public void BuildNetCoreWpfLarge(ProjectPerfOperation operation) { TestProjectFromPerfTestSourceRepository( operation: operation, testName: "Build WPF large", solutionDirectoryNameInPerfTestRepo: "WpfLarge", projectDirectoryName: "WpfLarge"); }
public void BuildWebLarge30(ProjectPerfOperation operation) { string sourceProject = Path.Combine(TestContext.GetRepoRoot(), ".perftestsource/PerformanceTestProjects/WebLarge30"); var testDir = _testAssetsManager.CreateTestDirectory("WebLarge30", identifier: operation.ToString()); Console.WriteLine($"Mirroring {sourceProject} to {testDir}..."); FolderSnapshot.MirrorFiles(sourceProject, testDir.Path); Console.WriteLine("Done"); TestProject(Path.Combine(testDir.Path, "mvc"), "Build Web Large 3.0", operation); }
public void BuildMVCApp(ProjectPerfOperation operation) { var testDir = _testAssetsManager.CreateTestDirectory(identifier: operation.ToString()); var newCommand = new DotnetCommand(Log); newCommand.WorkingDirectory = testDir.Path; newCommand.Execute("new", "mvc", "--no-restore").Should().Pass(); TestProject(testDir.Path, "ASP.NET Core MVC app", operation, "https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;https://api.nuget.org/v3/index.json"); }
public void BuildNetStandard2Library(ProjectPerfOperation operation) { var testProject = new TestProject() { Name = "NetCoreApp", TargetFrameworks = "netstandard2.0", IsSdkProject = true }; var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: operation.ToString()); TestProject(testAsset.Path, ".NET Standard 2.0 Library", operation); }
public void BuildMVCApp(ProjectPerfOperation operation) { var testDir = _testAssetsManager.CreateTestDirectory(identifier: operation.ToString()); NuGetConfigWriter.Write(testDir.Path, NuGetConfigWriter.AspNetCoreDevFeed); var newCommand = new DotnetCommand(Log); newCommand.WorkingDirectory = testDir.Path; newCommand.Execute("new", "mvc", "--no-restore").Should().Pass(); TestProject(testDir.Path, "ASP.NET Core MVC app", operation); }
public void BuildNetCore2App(ProjectPerfOperation operation) { var testProject = new TestProject() { Name = "NetCoreApp", TargetFrameworks = "netcoreapp2.0", IsSdkProject = true, IsExe = true }; var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: operation.ToString()); TestProject(testAsset.Path, ".NET Core 2 Console App", operation); }
public void BuildNetCoreWindowsFormsHelloWorld(ProjectPerfOperation operation) { var testDir = _testAssetsManager.CreateTestDirectory(identifier: operation.ToString()); NuGetConfigWriter.Write(testDir.Path, NuGetConfigWriter.DotnetCoreBlobFeed); var newCommand = new DotnetCommand(Log); newCommand.WorkingDirectory = testDir.Path; newCommand.Execute("new", "winforms", "--no-restore").Should().Pass(); TestProject(testDir.Path, "Windows Forms hello world", operation); }
private void TestProject(string projectFolderOrFile, string testName, ProjectPerfOperation perfOperation, string restoreSources = null) { string testProjectPath; string testProjectDirectory; bool projectFileSpecified; if (File.Exists(projectFolderOrFile)) { projectFileSpecified = true; testProjectPath = projectFolderOrFile; testProjectDirectory = Path.GetDirectoryName(projectFolderOrFile); } else { projectFileSpecified = false; testProjectPath = Directory.GetFiles(projectFolderOrFile, "*.sln", SearchOption.AllDirectories).SingleOrDefault(); if (testProjectPath == null) { testProjectPath = Directory.GetFiles(projectFolderOrFile, "*.csproj", SearchOption.AllDirectories).SingleOrDefault(); if (testProjectPath == null) { throw new ArgumentException("Could not find project file to test in folder: " + projectFolderOrFile); } } testProjectDirectory = Path.GetDirectoryName(testProjectPath); } TestCommand commandToTest; var perfTest = new PerfTest(); perfTest.ScenarioName = testName; if (perfOperation == ProjectPerfOperation.NoOpRestore) { TestCommand restoreCommand; if (TestContext.Current.ToolsetUnderTest.ShouldUseFullFrameworkMSBuild) { restoreCommand = new RestoreCommand(Log, testProjectPath); } else { restoreCommand = new RestoreCommand(Log, testProjectPath); restoreCommand = new DotnetCommand(Log, "restore"); if (projectFileSpecified) { restoreCommand.Arguments.Add(testProjectPath); } } if (!string.IsNullOrEmpty(restoreSources)) { restoreCommand.Arguments.Add($"/p:RestoreSources={restoreSources}"); } restoreCommand.WorkingDirectory = testProjectDirectory; restoreCommand.Execute().Should().Pass(); commandToTest = restoreCommand; perfTest.TestName = "Restore (No-op)"; } else { if (TestContext.Current.ToolsetUnderTest.ShouldUseFullFrameworkMSBuild) { commandToTest = new BuildCommand(Log, projectFileSpecified ? testProjectPath : testProjectDirectory); commandToTest.Arguments.Add("/restore"); } else { commandToTest = new DotnetCommand(Log, "build"); if (projectFileSpecified) { commandToTest.Arguments.Add(testProjectPath); } } if (!string.IsNullOrEmpty(restoreSources)) { commandToTest.Arguments.Add($"/p:RestoreSources={restoreSources}"); } commandToTest.WorkingDirectory = testProjectDirectory; if (perfOperation == ProjectPerfOperation.CleanBuild) { perfTest.TestName = "Build"; } else if (perfOperation == ProjectPerfOperation.BuildWithNoChanges) { // Build once before taking folder snaspshot commandToTest.Execute().Should().Pass(); perfTest.TestName = "Build (no changes)"; } else { throw new ArgumentException("Unexpected perf operation: " + perfOperation); } } perfTest.ProcessToMeasure = commandToTest.GetProcessStartInfo(); perfTest.TestFolder = testProjectDirectory; perfTest.Run(); }