{
using (var setupSection = new IndentedTestOutputHelper("Setup " + Name, output))
{
- await SetupHelloWorldProject(dotNetInstall.DotNetExe, intermediateOutputDir, useExistingSetup, setupSection);
+ await SetupHelloWorldProject(dotNetInstall, intermediateOutputDir, useExistingSetup, setupSection);
}
}
- protected async Task SetupHelloWorldProject(string dotNetExePath, string intermediateOutputDir, bool useExistingSetup, ITestOutputHelper output)
+ protected async Task SetupHelloWorldProject(DotNetInstallation dotNetInstall, string intermediateOutputDir, bool useExistingSetup, ITestOutputHelper output)
{
string helloWorldProjectDir = Path.Combine(intermediateOutputDir, "helloworld");
//the 'exePath' gets passed as an argument to dotnet.exe
{
FileTasks.DeleteDirectory(helloWorldProjectDir, output);
FileTasks.CreateDirectory(helloWorldProjectDir, output);
- await new ProcessRunner(dotNetExePath, "new console")
+ await new ProcessRunner(dotNetInstall.DotNetExe, "new console")
.WithWorkingDirectory(helloWorldProjectDir)
.WithLog(output)
.Run();
+
+ RetargetProjects(dotNetInstall, helloWorldProjectDir, new string[] { "helloworld.csproj" });
}
}
}
{
class MusicStoreBenchmark : WebAppBenchmark
{
- public MusicStoreBenchmark() : base("MusicStore", "MusicStore.dll") { }
+ public MusicStoreBenchmark() :
+ base(
+ "MusicStore",
+ "MusicStore.dll",
+ new string[] { Path.Combine("src", "MusicStore", "MusicStore.csproj") })
+ { }
protected override string GetJitBenchRepoRootDir(string outputDir)
{
class AllReadyBenchmark : WebAppBenchmark
{
- public AllReadyBenchmark() : base("AllReady", "AllReady.dll") { }
+ public AllReadyBenchmark() :
+ base(
+ "AllReady",
+ "AllReady.dll",
+ new string[] { Path.Combine("src", "AllReady", "AllReady.csproj") })
+ { }
protected override string GetJitBenchRepoRootDir(string outputDir)
{
{
private static readonly HashSet<int> DefaultExitCodes = new HashSet<int>(new[] { 0 });
- public WebAppBenchmark(string name, string executableName) : base(name)
+ private string[] _projectFileRelativePaths;
+
+ public WebAppBenchmark(string name, string executableName, string[] projectFileRelativePaths) : base(name)
{
ExePath = executableName;
+ _projectFileRelativePaths = projectFileRelativePaths;
}
public override async Task Setup(DotNetInstallation dotNetInstall, string outputDir, bool useExistingSetup, ITestOutputHelper output)
using (var setupSection = new IndentedTestOutputHelper("Setup " + Name, output))
{
await CloneAspNetJitBenchRepo(outputDir, setupSection);
+ RetargetProjects(dotNetInstall, GetJitBenchRepoRootDir(outputDir), _projectFileRelativePaths);
await CreateStore(dotNetInstall, outputDir, setupSection);
await Publish(dotNetInstall, outputDir, setupSection);
}
publishDir = GetWebAppPublishDirectory(dotNetInstall, outputDir, tfm);
if (publishDir == null)
{
- throw new DirectoryNotFoundException("Could not find 'publish' directory");
+ throw new DirectoryNotFoundException($"Could not find 'publish' directory: {publishDir}");
}
return publishDir;
}
using (var setupSection = new IndentedTestOutputHelper("Setup " + Name, output))
{
await CloneWord2VecNetRepo(outputDir, setupSection);
+ RetargetProjects(
+ dotNetInstall,
+ GetWord2VecNetRepoRootDir(outputDir),
+ new string[]
+ {
+ Path.Combine("Word2Vec.Net", "Word2Vec.Net.csproj"),
+ Path.Combine("Word2VecScenario", "Word2VecScenario.csproj")
+ });
await Publish(dotNetInstall, outputDir, setupSection);
await DownloadAndExtractTextCorpus(dotNetInstall, outputDir, setupSection);
}
publishDir = GetWord2VecNetPublishDirectory(dotNetInstall, outputDir, tfm);
if (publishDir == null)
{
- throw new DirectoryNotFoundException("Could not find 'publish' directory");
+ throw new DirectoryNotFoundException($"Could not find 'publish' directory: {publishDir}");
}
return publishDir;
}
--- /dev/null
+<Project>
+ <!--
+ MSBuild automatically imports this project into any projects in the current or child folders. The projects under this
+ folder directly import what they need, and this file exists just to prevent the auto-import.
+ -->
+</Project>
--- /dev/null
+<Project>
+ <!--
+ MSBuild automatically imports this project into any projects in the current or child folders. The projects under this
+ folder directly import what they need, and this file exists just to prevent the auto-import.
+ -->
+</Project>
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
+using System.Xml;
using Microsoft.Xunit.Performance.Api;
using Microsoft.Xunit.Performance.Api.Profilers.Etw;
public abstract Task Setup(DotNetInstallation dotnetInstall, string intermediateOutputDir, bool useExistingSetup, ITestOutputHelper output);
+ protected void RetargetProjects(
+ DotNetInstallation dotNetInstall,
+ string rootDir,
+ IEnumerable<string> projectFileRelativePaths)
+ {
+ if (string.IsNullOrWhiteSpace(rootDir))
+ {
+ throw new ArgumentNullException(rootDir);
+ }
+ if (!Directory.Exists(rootDir))
+ {
+ throw new DirectoryNotFoundException($"Root directory was not found: {rootDir}");
+ }
+
+ foreach (string projectFileRelativePath in projectFileRelativePaths)
+ {
+ string projectFile = Path.Combine(rootDir, projectFileRelativePath);
+ if (!File.Exists(projectFile))
+ {
+ throw new FileNotFoundException($"Project file was not found: {projectFile}");
+ }
+
+ var doc = new XmlDocument();
+ Encoding docEncoding;
+ using (var fs = new FileStream(projectFile, FileMode.Open, FileAccess.Read, FileShare.Read))
+ using (var sr = new StreamReader(fs))
+ {
+ docEncoding = sr.CurrentEncoding;
+ doc.Load(sr);
+ }
+ XmlElement root = doc.DocumentElement;
+
+ // Comment out all existing TargetFramework and RuntimeFrameworkVersion elements
+ foreach (XmlElement e in root.SelectNodes("PropertyGroup/TargetFramework").OfType<XmlElement>())
+ {
+ e.ParentNode.ReplaceChild(doc.CreateComment(e.OuterXml), e);
+ }
+ foreach (XmlElement e in root.SelectNodes("PropertyGroup/RuntimeFrameworkVersion").OfType<XmlElement>())
+ {
+ e.ParentNode.ReplaceChild(doc.CreateComment(e.OuterXml), e);
+ }
+
+ // Add TargetFramework and RuntimeFrameworkVersion elements with the requested values to the top
+ {
+ XmlElement propertyGroupElement = doc.CreateElement("PropertyGroup");
+ root.PrependChild(propertyGroupElement);
+
+ XmlElement targetFrameworkElement = doc.CreateElement("TargetFramework");
+ XmlElement runtimeFrameworkVersionElement = doc.CreateElement("RuntimeFrameworkVersion");
+ propertyGroupElement.AppendChild(targetFrameworkElement);
+ propertyGroupElement.AppendChild(runtimeFrameworkVersionElement);
+
+ targetFrameworkElement.InnerText =
+ DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion);
+ runtimeFrameworkVersionElement.InnerText = dotNetInstall.FrameworkVersion;
+ }
+
+ using (var fs = new FileStream(projectFile, FileMode.Truncate, FileAccess.Write, FileShare.Read))
+ using (var sw = new StreamWriter(fs, docEncoding))
+ {
+ doc.Save(sw);
+ }
+ }
+ }
+
public virtual Metric[] GetDefaultDisplayMetrics()
{
return new Metric[] { Metric.ElapsedTimeMilliseconds };
public BenchmarkConfiguration WithMinOpts()
{
- return WithModifier("Minopts", "COMPLUS_JitMinOpts", "1");
+ BenchmarkConfiguration configuration =
+ WithModifier("Minopts", "COMPLUS_JitMinOpts", "1").
+ WithModifier("Tiering", "COMPLUS_TieredCompilation", "0");
+ configuration.Name = "Minopts";
+ return configuration;
}
public BenchmarkConfiguration WithNoR2R()
public static string GetTargetFrameworkMonikerForFrameworkVersion(string runtimeVersion)
{
- if(runtimeVersion.StartsWith("2.0"))
+ if (runtimeVersion.StartsWith("3.0"))
{
- return "netcoreapp2.0";
+ return "netcoreapp3.0";
}
- else if(runtimeVersion.StartsWith("2.1"))
+ else if (runtimeVersion.StartsWith("2.1"))
{
return "netcoreapp2.1";
}
+ else if (runtimeVersion.StartsWith("2.0"))
+ {
+ return "netcoreapp2.0";
+ }
else
{
throw new NotSupportedException("Version " + runtimeVersion + " doesn't have a known TFM");
public static string GetCompatibleDefaultSDKVersionForRuntimeTFM(string targetFrameworkMoniker)
{
- if (targetFrameworkMoniker == "netcoreapp2.0")
+ if (targetFrameworkMoniker == "netcoreapp3.0")
{
- return "2.0.0";
+ return "3.0.100-alpha1-009410";
}
else if (targetFrameworkMoniker == "netcoreapp2.1")
{
return "2.2.0-preview1-007558";
}
+ else if (targetFrameworkMoniker == "netcoreapp2.0")
+ {
+ return "2.0.9";
+ }
else
{
throw new Exception("No compatible SDK version has been designated for TFM: " + targetFrameworkMoniker);
<Project Sdk="Microsoft.NET.Sdk">
- <!--The common test dirs props expects Platform to be empty in order to initialize it and
- by default this project style appears to set it as "AnyCPU" so we need to clear it -->
- <PropertyGroup>
- <Platform></Platform>
- <Platforms>AnyCPU;x64</Platforms>
- <Configuration></Configuration>
- </PropertyGroup>
-
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+
<PropertyGroup>
+ <Platform Condition="'$(Platform)' == ''">AnyCPU</Platform>
+ <Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
- <!-- the common test dirs props pushes all tests to use a more recent NTM unless we explictly opt-out -->
+ <!-- The common test dirs props pushes all tests to use a more recent NTM unless we explictly opt-out -->
<NuGetTargetMoniker>.NETCoreApp,Version=v2.0</NuGetTargetMoniker>
<NuGetTargetMonikerShort>netcoreapp2.0</NuGetTargetMonikerShort>
</PropertyGroup>
<Compile Include="$(BaseIntermediateOutputPath)AutoGeneratedVersioningConstants.cs" />
</ItemGroup>
- <Target Name="GenerateVersioningConstantsFile" BeforeTargets="CoreCompile">
- <WriteLinesToFile File="$(BaseIntermediateOutputPath)AutoGeneratedVersioningConstants.cs" Lines="@(VersioningConstantsLines)" Overwrite="true" Encoding="Unicode" />
- </Target>
-
- <!-- The CoreCLR test build system requires a target named RestorePackage in order to do BatchRestore -->
- <Target Name="RestorePackage" DependsOnTargets="Restore" />
+ <Target Name="GenerateVersioningConstantsFile" BeforeTargets="CoreCompile">
+ <WriteLinesToFile File="$(BaseIntermediateOutputPath)AutoGeneratedVersioningConstants.cs" Lines="@(VersioningConstantsLines)" Overwrite="true" Encoding="Unicode" />
+ </Target>
</Project>