This commit is contained in:
Pavel Krymets 2016-04-27 08:44:12 -07:00
parent cdb75966eb
commit 1104e56895
29 changed files with 101 additions and 163 deletions

View file

@ -6,6 +6,7 @@ namespace ConsoleApplication
{
public static void Main()
{
ConsoleLibrary.P1.Program.Main();
}
}
}

View file

@ -1,11 +1,12 @@
using System;
namespace ConsoleApplication
namespace ConsoleLibrary.P1
{
public class Program
{
public static void Main()
{
ConsoleLibrary.P2.Program.Main();
}
}
}

View file

@ -1,8 +1,5 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"SingleTargetP2" : {
"target": "project"

View file

@ -1,6 +1,6 @@
using System;
namespace ConsoleApplication
namespace ConsoleLibrary.P2
{
public class Program
{

View file

@ -1,8 +1,5 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",

View file

@ -6,6 +6,7 @@ namespace ConsoleApplication
{
public static void Main()
{
ConsoleLibrary.P1.Program.Main();
}
}
}

View file

@ -1,11 +1,12 @@
using System;
namespace ConsoleApplication
namespace ConsoleLibrary.P1
{
public class Program
{
public static void Main()
{
ConsoleLibrary.P2.Program.Main();
}
}
}

View file

@ -1,8 +1,5 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"TwoTargetP2" : {
"target": "project"

View file

@ -1,6 +1,6 @@
using System;
namespace ConsoleApplication
namespace ConsoleLibrary.P2
{
public class Program
{

View file

@ -1,8 +1,5 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",

View file

@ -6,6 +6,7 @@ namespace ConsoleApplication
{
public static void Main()
{
ConsoleLibrary.P1.Program.Main();
}
}
}

View file

@ -1,11 +1,13 @@
using System;
namespace ConsoleApplication
namespace ConsoleLibrary.P1
{
public class Program
{
public static void Main()
{
ConsoleLibrary.P2.Program.Main();
ConsoleLibrary.P4.Program.Main();
}
}
}

View file

@ -1,8 +1,5 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"TwoTargetLargeP2" : {
"target": "project"

View file

@ -1,11 +1,13 @@
using System;
namespace ConsoleApplication
namespace ConsoleLibrary.P2
{
public class Program
{
public static void Main()
{
ConsoleLibrary.P3.Program.Main();
ConsoleLibrary.P4.Program.Main();
}
}
}

View file

@ -1,8 +1,5 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"TwoTargetLargeP3" : {
"target": "project"

View file

@ -1,11 +1,12 @@
using System;
namespace ConsoleApplication
namespace ConsoleLibrary.P3
{
public class Program
{
public static void Main()
{
ConsoleLibrary.P4.Program.Main();
}
}
}

View file

@ -1,8 +1,5 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"TwoTargetLargeP4" : {
"target": "project"

View file

@ -1,11 +1,13 @@
using System;
namespace ConsoleApplication
namespace ConsoleLibrary.P4
{
public class Program
{
public static void Main()
{
ConsoleLibrary.P5.Program.Main();
ConsoleLibrary.P6.Program.Main();
}
}
}

View file

@ -1,8 +1,5 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"TwoTargetLargeP5" : {
"target": "project"

View file

@ -1,6 +1,6 @@
using System;
namespace ConsoleApplication
namespace ConsoleLibrary.P5
{
public class Program
{

View file

@ -1,8 +1,5 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",

View file

@ -1,6 +1,6 @@
using System;
namespace ConsoleApplication
namespace ConsoleLibrary.P6
{
public class Program
{

View file

@ -1,8 +1,5 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",

View file

@ -36,7 +36,8 @@ namespace Microsoft.DotNet.Cli.Build
"Microsoft.DotNet.Cli.Utils.Tests",
"Microsoft.DotNet.Compiler.Common.Tests",
"Microsoft.DotNet.ProjectModel.Tests",
"Microsoft.Extensions.DependencyModel.Tests"
"Microsoft.Extensions.DependencyModel.Tests",
"Performance"
};
public static readonly string[] WindowsTestProjects = new[]

View file

@ -8,7 +8,6 @@ using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Compiler.Common;
using Microsoft.DotNet.Cli.Utils;

View file

@ -5,10 +5,14 @@ using System.Linq;
using Microsoft.DotNet.Tools.Test.Utilities;
using Microsoft.Xunit.Performance;
using Microsoft.DotNet.TestFramework;
using System.IO;
using System.Runtime.CompilerServices;
using System;
using System.Collections.Generic;
namespace Microsoft.DotNet.Tools.Builder.Tests
{
public class BuildPerformanceTest : PerformanceTestBase
public class BuildPerformanceTest : TestBase
{
private static string SingleTargetApp = "SingleTargetApp";
private static string TwoTargetApp = "TwoTargetApp";
@ -47,11 +51,12 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
{
foreach (var iteration in Benchmark.Iterations)
{
var buildCommand = new BuildCommand(instance.TestRoot, buildProfile: false);
using (iteration.StartMeasurement())
{
Build(instance.TestRoot);
buildCommand.Execute().Should().Pass();
}
RemoveBin(instance.TestRoot);
TouchSource(instance.TestRoot);
}
}
@ -62,13 +67,15 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
public void IncrementalSkipSingleProject(TestInstance instance)
{
Build(instance.TestRoot);
new BuildCommand(instance.TestRoot, buildProfile: false)
.Execute().Should().Pass();
foreach (var iteration in Benchmark.Iterations)
{
var buildCommand = new BuildCommand(instance.TestRoot, buildProfile: false);
using (iteration.StartMeasurement())
{
Build(instance.TestRoot);
buildCommand.Execute().Should().Pass();
}
}
}
@ -86,13 +93,14 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
foreach (var iteration in Benchmark.Iterations)
{
var buildCommand = new BuildCommand(instance.TestRoot, buildProfile: false);
using (iteration.StartMeasurement())
{
Build(instance.TestRoot);
buildCommand.Execute().Should().Pass();
}
foreach (var i in instances)
{
RemoveBin(i.TestRoot);
TouchSource(i.TestRoot);
}
}
}
@ -112,14 +120,15 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
public void IncrementalSkipAllInGraph(TestInstance[] instances)
{
var instance = instances[0];
Build(instance.TestRoot);
new BuildCommand(instance.TestRoot, buildProfile: false)
.Execute().Should().Pass();
foreach (var iteration in Benchmark.Iterations)
{
var buildCommand = new BuildCommand(instance.TestRoot, buildProfile: false);
using (iteration.StartMeasurement())
{
Build(instance.TestRoot);
buildCommand.Execute().Should().Pass();
}
}
}
@ -139,16 +148,17 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
public void IncrementalRebuildWithRootChangedInGraph(TestInstance[] instances)
{
var instance = instances[0];
Build(instance.TestRoot);
new BuildCommand(instance.TestRoot, buildProfile: false)
.Execute().Should().Pass();
foreach (var iteration in Benchmark.Iterations)
{
var buildCommand = new BuildCommand(instance.TestRoot, buildProfile: false);
using (iteration.StartMeasurement())
{
Build(instance.TestRoot);
buildCommand.Execute().Should().Pass();
}
RemoveBin(instance.TestRoot);
TouchSource(instance.TestRoot);
}
}
@ -167,16 +177,17 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
public void IncrementalRebuildWithLastChangedInGraph(TestInstance[] instances)
{
var instance = instances[0];
Build(instance.TestRoot);
new BuildCommand(instance.TestRoot, buildProfile: false)
.Execute().Should().Pass();
foreach (var iteration in Benchmark.Iterations)
{
var buildCommand = new BuildCommand(instance.TestRoot, buildProfile: false);
using (iteration.StartMeasurement())
{
Build(instance.TestRoot);
buildCommand.Execute().Should().Pass();
}
RemoveBin(instances.Last().TestRoot);
TouchSource(instances.Last().TestRoot);
}
}
@ -196,25 +207,30 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
public void IncrementalSkipAllNoDependenciesInGraph(TestInstance[] instances)
{
var instance = instances[0];
Build(instance.TestRoot);
new BuildCommand(instance.TestRoot, buildProfile: false)
.Execute().Should().Pass();
foreach (var iteration in Benchmark.Iterations)
{
var commands = new List<BuildCommand>();
foreach (var i in instances.Reverse())
{
commands.Add(new BuildCommand(i.TestRoot,
framework: DefaultFramework,
noDependencies: true,
buildProfile: false));
}
using (iteration.StartMeasurement())
{
foreach (var i in instances)
foreach (var buildCommand in commands)
{
Run(new BuildCommand(i.TestRoot,
framework: DefaultFramework,
noDependencies: true,
buildProfile: false));
buildCommand.Execute().Should().Pass();
}
}
}
}
[Benchmark]
public void BuildAllNoDependenciesInGraphh_SingleTargetGraph() =>
public void BuildAllNoDependenciesInGraph_SingleTargetGraph() =>
BuildAllNoDependenciesInGraph(CreateTestInstances(SingleTargetGraph));
[Benchmark]
@ -229,21 +245,50 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
{
foreach (var iteration in Benchmark.Iterations)
{
var commands = new List<BuildCommand>();
foreach (var i in instances.Reverse())
{
commands.Add(new BuildCommand(i.TestRoot,
framework: DefaultFramework,
noDependencies: true,
buildProfile: false));
}
using (iteration.StartMeasurement())
{
foreach (var i in instances.Reverse())
foreach (var buildCommand in commands)
{
Run(new BuildCommand(i.TestRoot,
framework: DefaultFramework,
noDependencies: true,
buildProfile: false));
buildCommand.Execute().Should().Pass();
}
}
foreach (var instance in instances)
{
RemoveBin(instance.TestRoot);
TouchSource(instance.TestRoot);
}
}
}
protected void TouchSource(string project)
{
var sourceFile = Directory.GetFiles(project, "*.cs").FirstOrDefault();
if (sourceFile == null)
{
throw new InvalidOperationException($"'.cs' files not found in {project}");
}
File.SetLastWriteTime(sourceFile, DateTime.Now);
}
protected TestInstance[] CreateTestInstances(string[] testProjectNames, [CallerMemberName] string callingMethod = "")
{
return testProjectNames.Select(testProjectName =>
{
return CreateTestInstance(testProjectName, callingMethod);
}).ToArray();
}
protected TestInstance CreateTestInstance(string testProjectName, [CallerMemberName] string callingMethod = "")
{
return TestAssetsManager.CreateTestInstance(Path.Combine("PerformanceTestProjects", testProjectName), callingMethod)
.WithLockFiles();
}
}
}

View file

@ -1,40 +0,0 @@
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using Microsoft.DotNet.Tools.Test.Utilities;
using Microsoft.DotNet.TestFramework;
namespace Microsoft.DotNet.Tools.Builder.Tests
{
public class PerformanceTestBase : TestBase
{
protected void Build(string project)
{
Run(new BuildCommand(project, buildProfile: false));
}
protected void Run(TestCommand command)
{
command.Execute().Should().Pass();
}
protected void RemoveBin(string project)
{
Directory.Delete(Path.Combine(project, "bin"), true);
}
protected TestInstance[] CreateTestInstances(string[] testProjectNames, [CallerMemberName] string callingMethod = "")
{
return testProjectNames.Select(testProjectName =>
{
return CreateTestInstance(testProjectName, callingMethod);
}).ToArray();
}
protected TestInstance CreateTestInstance(string testProjectName, [CallerMemberName] string callingMethod = "")
{
return TestAssetsManager.CreateTestInstance(Path.Combine("PerformanceTestProjects", testProjectName), callingMethod)
.WithLockFiles();
}
}
}

View file

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.25123" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25123</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>0ae3d045-c119-4ed7-bd0c-287029b7264a</ProjectGuid>
<RootNamespace>dotnet-performance.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View file

@ -1,30 +0,0 @@
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.NETCore.App": "1.0.0-rc2-*",
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-24022",
"Microsoft.DotNet.Tools.Tests.Utilities": {
"target": "project"
},
"Microsoft.DotNet.Cli.Utils": {
"target": "project"
},
"Newtonsoft.Json": "7.0.1",
"xunit": "2.1.0",
"dotnet-test-xunit": "1.0.0-dev-140469-38",
"Microsoft.DotNet.xunit.performance": "1.0.0-alpha-build0028"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.4",
"portable-net451+win8"
]
}
},
"testRunner": "xunit",
"runtimes":
{
"win7-x64": {}
}
}