diff options
Diffstat (limited to 'tests/src/performance/linkbench')
6 files changed, 467 insertions, 206 deletions
diff --git a/tests/src/performance/linkbench/assets/MusicStore/Get-Crossgen.ps1 b/tests/src/performance/linkbench/assets/MusicStore/Get-Crossgen.ps1 new file mode 100644 index 0000000000..9a7cdf9802 --- /dev/null +++ b/tests/src/performance/linkbench/assets/MusicStore/Get-Crossgen.ps1 @@ -0,0 +1,77 @@ +# Gets crossgen.exe +# +# Downloads NuGet.exe +# Installs crossgen.exe and clrjit.dll using NuGet +# Copies the files to $path + +param([string]$path = ".") + +$ErrorActionPreference = "Stop" + +Write-Host -ForegroundColor Green "Installing crossgen.exe to $path" + +if (-not (Test-Path $path)) +{ + New-Item -Path $path -ItemType Directory -Force | Out-Null +} + +$path = Get-Item $path + +function Get-NETCoreAppVersion() +{ + if (-not (Test-Path $PSScriptRoot\obj\project.assets.json)) + { + Write-Error "project.assets.json is missing. do a dotnet restore." + exit + } + + # ConvertFrom-Json can't be used here as it has an arbitrary size limit. + [void][System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions") + $serializer = New-Object -TypeName System.Web.Script.Serialization.JavaScriptSerializer + $serializer.MaxJsonLength = 67108864 + + $json = $serializer.DeserializeObject((Get-Content $PSScriptRoot\obj\project.assets.json -Raw)) + + foreach ($name in $json["libraries"].Keys) + { + if ($name.StartsWith("Microsoft.NETCore.App/")) + { + $version = $name.SubString("Microsoft.NETCore.App/".Length) + break + } + } + + return $version +} + +$version = Get-NETCoreAppVersion +Write-Host -ForegroundColor Green "autodetected shared framework version $version" + +$platform = "win-x64" + +$netcoreapppackage = "runtime.$platform.microsoft.netcore.app" +$netcoreappversion = $version + +Write-Host -ForegroundColor Green "Getting NuGet.exe" + +$nugeturl = "https://dist.nuget.org/win-x86-commandline/v3.4.4/NuGet.exe" +$nugetfeed = "https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" +$nugetexepath = "$path\NuGet.exe" +$wc = New-Object System.Net.WebClient +$wc.DownloadFile($nugeturl, $nugetexepath) + + +Write-Host -ForegroundColor Green "Getting $netcoreapppackage $netcoreappversion" + +& "$nugetexepath" "install", "$netcoreapppackage", "-Source", "$nugetfeed", "-Version", "$netcoreappversion", "-OutputDirectory", "$path" +if ($LastExitCode -ne 0) { + throw "NuGet install of $netcoreapppackage failed." +} + +Copy-Item "$path\$netcoreapppackage.$netcoreappversion\tools\crossgen.exe" "$path\crossgen.exe" -Force +Copy-Item "$path\$netcoreapppackage.$netcoreappversion\runtimes\$platform\native\clrjit.dll" "$path\clrjit.dll" -Force +Remove-Item "$path\$netcoreapppackage.$netcoreappversion\" -recurse + +Remove-Item "$path\NuGet.exe" + +Write-Host -ForegroundColor Green "Success" diff --git a/tests/src/performance/linkbench/assets/Roslyn/illinkcsproj b/tests/src/performance/linkbench/assets/Roslyn/illinkcsproj index 1247c5e715..c8549e2d47 100644 --- a/tests/src/performance/linkbench/assets/Roslyn/illinkcsproj +++ b/tests/src/performance/linkbench/assets/Roslyn/illinkcsproj @@ -1,9 +1,10 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netcoreapp2.0</TargetFramework> - <RuntimeIdentifiers>win7-x86;win7-x64</RuntimeIdentifiers> + <OutputType>Exe</OutputType> + <TargetFramework>netcoreapp1.1</TargetFramework> </PropertyGroup> <ItemGroup> - <PackageReference Include="ILLink.Tasks" Version="0.1.0-preview" /> + <PackageReference Include="Microsoft.NETCore.ILLink" Version="0.1.9-preview" /> </ItemGroup> </Project> + diff --git a/tests/src/performance/linkbench/linkbench.cs b/tests/src/performance/linkbench/linkbench.cs index 3d29957f90..ad0f83ef0e 100644 --- a/tests/src/performance/linkbench/linkbench.cs +++ b/tests/src/performance/linkbench/linkbench.cs @@ -1,3 +1,5 @@ +using Microsoft.Xunit.Performance; +using Microsoft.Xunit.Performance.Api; using System; using System.Diagnostics; using System.Collections.Generic; @@ -8,8 +10,6 @@ using System.Text; using System.Globalization; using System.Linq; using System.Xml.Linq; -using Microsoft.Xunit.Performance; -using Microsoft.Xunit.Performance.Api; using Xunit; using Xunit.Abstractions; @@ -18,7 +18,8 @@ namespace LinkBench public class Benchmark { public string Name; - + public bool ShouldRun; + public string ProjFile; public string UnlinkedDir; public string LinkedDir; public double UnlinkedMsilSize; @@ -28,18 +29,29 @@ namespace LinkBench public double MsilSizeReduction; public double DirSizeReduction; + public delegate void SetupDelegate(); + public SetupDelegate Setup; + private DirectoryInfo unlinkedDirInfo; private DirectoryInfo linkedDirInfo; private double certDiff; const double MB = 1024 * 1024; - public Benchmark(string _Name, string _UnlinkedDir, string _LinkedDir) + public Benchmark(string _Name, string _UnlinkedDir, string _LinkedDir, SetupDelegate _setup = null, bool _shouldRun = false) { Name = _Name; UnlinkedDir = _UnlinkedDir; LinkedDir = _LinkedDir; unlinkedDirInfo = new DirectoryInfo(UnlinkedDir); linkedDirInfo = new DirectoryInfo(LinkedDir); + ShouldRun = _shouldRun; + Setup = _setup; + } + + public void SetToRun() + { + ShouldRun = true; + Environment.SetEnvironmentVariable("__test_" + Name, "true"); } public void Compute() @@ -50,8 +62,8 @@ namespace LinkBench UnlinkedDirSize = GetDirSize(unlinkedDirInfo); LinkedDirSize = GetDirSize(linkedDirInfo); - MsilSizeReduction = (UnlinkedMsilSize - LinkedMsilSize) / UnlinkedMsilSize * 100; - DirSizeReduction = (UnlinkedDirSize - LinkedDirSize) / UnlinkedDirSize * 100; + MsilSizeReduction = LinkedMsilSize / UnlinkedMsilSize; + DirSizeReduction = LinkedDirSize / UnlinkedDirSize; } // Compute total size of a directory, in MegaBytes @@ -82,20 +94,10 @@ namespace LinkBench foreach (string file in files) { - if (file.EndsWith(".ni.dll") || file.EndsWith(".ni.exe")) + if (IsMSIL(file)) { - continue; + msilSize += new FileInfo(file).Length; } - try - { - AssemblyLoadContext.GetAssemblyName(file); - } - catch (BadImageFormatException) - { - continue; - } - - msilSize += new FileInfo(file).Length; } return msilSize / MB; @@ -126,22 +128,104 @@ namespace LinkBench foreach (string file in files) { - try + if (IsMSIL(file)) { - AssemblyLoadContext.GetAssemblyName(file); + FileInfo fileInfo = new FileInfo(file); + long linkedCert = GetCertSize(file); + long unlinkedCert = GetCertSize(UnlinkedDir + "\\" + fileInfo.Name); + totalDiff += (unlinkedCert - linkedCert); } - catch (BadImageFormatException) + } + + return totalDiff / MB; + } + + //Use AssemblyLoadContext.GetAssemblyName(file); + private bool IsMSIL(string file) + { + if (file.EndsWith(".ni.dll") || file.EndsWith(".ni.exe")) + { + // Likely Native Image. + return false; + } + + try + { + AssemblyLoadContext.GetAssemblyName(file); + } + catch (Exception) + { + // We should check only for BadImageFormatException. + // But Checking for any exception until the following + // issue is fixed: + // https://github.com/dotnet/coreclr/issues/11499 + + return false; + } + + return true; + } + + public static void AddLinkerReference(string csproj) + { + var xdoc = XDocument.Load(csproj); + var ns = xdoc.Root.GetDefaultNamespace(); + bool added = false; + foreach (var el in xdoc.Root.Elements(ns + "ItemGroup")) + { + if (el.Elements(ns + "PackageReference").Any()) { - continue; + el.Add(new XElement(ns + "PackageReference", + new XAttribute("Include", "ILLink.Tasks"), + new XAttribute("Version", "0.1.4-preview"))); + added = true; + break; } + } + if (!added) + { + xdoc.Root.Add(new XElement(ns + "ItemGroup", + new XElement(ns + "PackageReference", + new XAttribute("Include", "ILLink.Tasks"), + new XAttribute("Version", "0.1.4-preview")))); + added = true; + } + using (var fs = new FileStream(csproj, FileMode.Create)) + { + xdoc.Save(fs); + } + } - FileInfo fileInfo = new FileInfo(file); - long linkedCert = GetCertSize(file); - long unlinkedCert = GetCertSize(UnlinkedDir + "\\" + fileInfo.Name); - totalDiff += (unlinkedCert - linkedCert); + // TODO: remove this once the linker is able to handle + // ready-to-run assembies + public static void SetRuntimeFrameworkVersion(string csproj) + { + var xdoc = XDocument.Load(csproj); + var ns = xdoc.Root.GetDefaultNamespace(); + var versionElement = xdoc.Root.Descendants(ns + "RuntimeFrameworkVersion").First(); + string runtimeFrameworkVersion = "2.0.0-preview2-002093-00"; + versionElement.Value = runtimeFrameworkVersion; + using (var fs = new FileStream(csproj, FileMode.Create)) + { + xdoc.Save(fs); } + } - return totalDiff / MB; + // TODO: Remove this once we figure out what to do about apps + // that have the publish output filtered by a manifest + // file. It looks like aspnet has made this the default. See + // the bug at https://github.com/dotnet/sdk/issues/1160. + public static void PreventPublishFiltering(string csproj) + { + var xdoc = XDocument.Load(csproj); + var ns = xdoc.Root.GetDefaultNamespace(); + var propertygroup = xdoc.Root.Element(ns + "PropertyGroup"); + propertygroup.Add(new XElement(ns + "PublishWithAspNetCoreTargetManifest", + "false")); + using (var fs = new FileStream(csproj, FileMode.Create)) + { + xdoc.Save(fs); + } } } @@ -149,42 +233,132 @@ namespace LinkBench { private static ScenarioConfiguration scenarioConfiguration = new ScenarioConfiguration(new TimeSpan(2000000)); private static MetricModel SizeMetric = new MetricModel { Name = "Size", DisplayName = "File Size", Unit = "MB" }; - private static MetricModel PercMetric = new MetricModel { Name = "Perc", DisplayName = "% Reduction", Unit = "%" }; + private static MetricModel PercMetric = new MetricModel { Name = "Ratio", DisplayName = "Reduction", Unit = "Linked/Unlinked" }; public static string Workspace; + public static string LinkBenchRoot; public static string ScriptDir; public static string AssetsDir; private static Benchmark CurrentBenchmark; + private static Benchmark[] Benchmarks = + { + new Benchmark("HelloWorld", + "HelloWorld\\bin\\release\\netcoreapp2.0\\win10-x64\\unlinked", + "HelloWorld\\bin\\release\\netcoreapp2.0\\win10-x64\\linked", + () => Benchmark.AddLinkerReference("HelloWorld\\HelloWorld.csproj")), + new Benchmark("WebAPI", + "WebAPI\\bin\\release\\netcoreapp2.0\\win10-x64\\unlinked", + "WebAPI\\bin\\release\\netcoreapp2.0\\win10-x64\\linked", + () => { Benchmark.AddLinkerReference("WebAPI\\WebAPI.csproj"); + Benchmark.PreventPublishFiltering("WebAPI\\WebAPI.csproj"); }), + //Remove the MusicStore from the run as the scenario is currently flaky and breaking performance runs + /*new Benchmark("MusicStore", + "JitBench\\src\\MusicStore\\bin\\release\\netcoreapp2.0\\win10-x64\\unlinked", + "JitBench\\src\\MusicStore\\bin\\release\\netcoreapp2.0\\win10-x64\\linked", + () => { Benchmark.AddLinkerReference("JitBench\\src\\MusicStore\\MusicStore.csproj"); + Benchmark.SetRuntimeFrameworkVersion("JitBench\\src\\MusicStore\\MusicStore.csproj"); }), + new Benchmark("MusicStore_R2R", + "JitBench\\src\\MusicStore\\bin\\release\\netcoreapp2.0\\win10-x64\\R2R\\unlinked", + "JitBench\\src\\MusicStore\\bin\\release\\netcoreapp2.0\\win10-x64\\R2R\\linked"),*/ + new Benchmark("Corefx", + "corefx\\bin\\ILLinkTrimAssembly\\netcoreapp-Windows_NT-Release-x64\\pretrimmed", + "corefx\\bin\\ILLinkTrimAssembly\\netcoreapp-Windows_NT-Release-x64\\trimmed"), + /*new Benchmark("Roslyn", + "roslyn\\Binaries\\Release\\Exes\\CscCore\\win7-x64\\publish", + "roslyn\\Binaries\\Release\\Exes\\CscCore\\win7-x64\\Linked") */ + }; + + static int UsageError() + { + Console.WriteLine("Usage: LinkBench [--nosetup] [--nobuild] [--perf:runid <id>] [<benchmarks>]"); + Console.WriteLine(" --nosetup: Don't clone and fixup benchmark repositories"); + Console.WriteLine(" --nosetup: Don't build and link benchmarks"); + Console.WriteLine(" --perf:runid: Specify the ID to append to benchmark result files"); + Console.WriteLine(" Benchmarks: HelloWorld, WebAPI, MusicStore, MusicStore_R2R, CoreFX, Roslyn"); + Console.WriteLine(" Default is to run all the above benchmarks."); + return -4; + } + public static int Main(String [] args) { - // Workspace is the ROOT of the coreclr tree. - // If CORECLR_REPO is not set, the script assumes that the location of sandbox - // is <path>\coreclr\sandbox. - bool doClone = true; + bool doSetup = true; bool doBuild = true; + string runId = ""; + string runOne = null; + bool benchmarkSpecified = false; - for(int i=0; i < args.Length; i++) + for (int i = 0; i < args.Length; i++) { - if (String.Compare(args[i], "noclone", true) == 0) + if (String.Compare(args[i], "--nosetup", true) == 0) { - doClone = false; + doSetup = false; } - else if (String.Compare(args[i], "nobuild", true) == 0) + else if (String.Compare(args[i], "--nobuild", true) == 0) { - doClone = false; + doSetup = false; doBuild = false; } + else if (String.Compare(args[i], "--perf:runid", true) == 0) + { + if (i + 1 < args.Length) + { + runId = args[++i] + "-"; + } + else + { + Console.WriteLine("Missing runID "); + return UsageError(); + } + } + else if (args[i][0] == '-') + { + Console.WriteLine("Unknown Option {0}", args[i]); + return UsageError(); + } else { - Console.WriteLine("Unknown argument"); - return -4; + foreach (Benchmark benchmark in Benchmarks) + { + if (String.Compare(args[i], benchmark.Name, true) == 0) + { + benchmark.SetToRun(); + benchmarkSpecified = true; + break; + } + } + + if (!benchmarkSpecified) + { + Console.WriteLine("Unknown Benchmark {0}", args[i]); + } } } + // If benchmarks are not explicitly specified, run all benchmarks + if (!benchmarkSpecified) + { + foreach (Benchmark benchmark in Benchmarks) + { + if (String.Compare(benchmark.Name, "CoreFX", true) == 0) + { + // CoreFX is not enabled by default, because the lab cannot run it yet. + // Jenkins runs on an older OS with path-length limit, which causes + // CoreFX build to fail. + continue; + } + + benchmark.SetToRun(); + } + } + + // Workspace is the ROOT of the coreclr tree. + // If CORECLR_REPO is not set, the script assumes that the location of sandbox + // is <path>\coreclr\sandbox. + LinkBenchRoot = Directory.GetCurrentDirectory(); Workspace = Environment.GetEnvironmentVariable("CORECLR_REPO"); if (Workspace == null) { - Workspace = Directory.GetParent(Directory.GetCurrentDirectory()).FullName; + Workspace = Directory.GetParent(LinkBenchRoot).FullName; } if (Workspace == null) { @@ -192,38 +366,38 @@ namespace LinkBench return -1; } - string LinkBenchDir = Workspace + "\\tests\\src\\performance\\linkbench\\"; - ScriptDir = LinkBenchDir + "scripts\\"; - AssetsDir = LinkBenchDir + "assets\\"; + string linkBenchSrcDir = Workspace + "\\tests\\src\\performance\\linkbench\\"; + ScriptDir = linkBenchSrcDir + "scripts\\"; + AssetsDir = linkBenchSrcDir + "assets\\"; - Benchmark[] Benchmarks = - { - new Benchmark("HelloWorld", - "LinkBench\\HelloWorld\\bin\\release\\netcoreapp2.0\\win10-x64\\publish", - "LinkBench\\HelloWorld\\bin\\release\\netcoreapp2.0\\win10-x64\\linked"), - new Benchmark("WebAPI", - "LinkBench\\WebAPI\\bin\\release\\netcoreapp2.0\\win10-x64\\publish", - "LinkBench\\WebAPI\\bin\\release\\netcoreapp2.0\\win10-x64\\linked"), - new Benchmark("MusicStore", - "LinkBench\\JitBench\\src\\MusicStore\\bin\\release\\netcoreapp2.0\\win10-x64\\publish", - "LinkBench\\JitBench\\src\\MusicStore\\bin\\release\\netcoreapp2.0\\win10-x64\\linked"), - new Benchmark("MusicStore_R2R", - "LinkBench\\JitBench\\src\\MusicStore\\bin\\release\\netcoreapp2.0\\win10-x64\\publish_r2r", - "LinkBench\\JitBench\\src\\MusicStore\\bin\\release\\netcoreapp2.0\\win10-x64\\linked_r2r"), - new Benchmark("Corefx", - "LinkBench\\corefx\\bin\\ILLinkTrimAssembly\\netcoreapp-Windows_NT-Release-x64\\pretrimmed", - "LinkBench\\corefx\\bin\\ILLinkTrimAssembly\\netcoreapp-Windows_NT-Release-x64\\trimmed"), - new Benchmark("Roslyn", - "LinkBench\\roslyn\\Binaries\\Release\\Exes\\CscCore", - "LinkBench\\roslyn\\Binaries\\Release\\Exes\\Linked"), - }; + Environment.SetEnvironmentVariable("LinkBenchRoot", LinkBenchRoot); + Environment.SetEnvironmentVariable("__dotnet1", LinkBenchRoot + "\\.Net1\\dotnet.exe"); + Environment.SetEnvironmentVariable("__dotnet2", LinkBenchRoot + "\\.Net2\\dotnet.exe"); // Update the build files to facilitate the link step - if(doClone) + if (doSetup) { - if(!Setup()) + // Clone the benchmarks + using (var setup = new Process()) { - return -2; + setup.StartInfo.FileName = ScriptDir + "clone.cmd"; + setup.Start(); + setup.WaitForExit(); + if (setup.ExitCode != 0) + { + Console.WriteLine("Benchmark Setup failed"); + return -2; + } + } + + // Setup the benchmarks + + foreach (Benchmark benchmark in Benchmarks) + { + if (benchmark.ShouldRun && benchmark.Setup != null) + { + benchmark.Setup(); + } } } @@ -238,7 +412,7 @@ namespace LinkBench setup.WaitForExit(); if (setup.ExitCode != 0) { - Console.WriteLine("Setup failed"); + Console.WriteLine("Benchmark build failed"); return -3; } } @@ -255,8 +429,12 @@ namespace LinkBench for (int i = 0; i < Benchmarks.Length; i++) { CurrentBenchmark = Benchmarks[i]; - string[] scriptArgs = { "--perf:runid", CurrentBenchmark.Name }; + if (!CurrentBenchmark.ShouldRun) + { + continue; + } + string[] scriptArgs = { "--perf:runid", runId + CurrentBenchmark.Name }; using (var h = new XunitPerformanceHarness(scriptArgs)) { h.RunScenario(emptyCmd, null, null, PostRun, scenarioConfiguration); @@ -280,81 +458,14 @@ namespace LinkBench addMeasurement(ref scenario, "MSIL Unlinked", SizeMetric, CurrentBenchmark.UnlinkedMsilSize); addMeasurement(ref scenario, "MSIL Linked", SizeMetric, CurrentBenchmark.LinkedMsilSize); - addMeasurement(ref scenario, "MSIL %Reduction", PercMetric, CurrentBenchmark.MsilSizeReduction); + addMeasurement(ref scenario, "MSIL Reduction", PercMetric, CurrentBenchmark.MsilSizeReduction); addMeasurement(ref scenario, "Total Uninked", SizeMetric, CurrentBenchmark.UnlinkedDirSize); addMeasurement(ref scenario, "Total Linked", SizeMetric, CurrentBenchmark.LinkedDirSize); - addMeasurement(ref scenario, "Total %Reduction", PercMetric, CurrentBenchmark.DirSizeReduction); + addMeasurement(ref scenario, "Total Reduction", PercMetric, CurrentBenchmark.DirSizeReduction); return scenario; } - private static bool Setup() - { - // Clone the benchmarks - using (var setup = new Process()) - { - setup.StartInfo.FileName = ScriptDir + "clone.cmd"; - Console.WriteLine("Run {0}", setup.StartInfo.FileName); - setup.Start(); - setup.WaitForExit(); - if (setup.ExitCode != 0) - { - Console.WriteLine("clone failed"); - return false; - } - } - - //Update the project files - AddLinkerReference("LinkBench\\HelloWorld\\HelloWorld.csproj"); - AddLinkerReference("LinkBench\\WebAPI\\WebAPI.csproj"); - AddLinkerReference("LinkBench\\JitBench\\src\\MusicStore\\MusicStore.csproj"); - RemoveCrossgenTarget("LinkBench\\JitBench\\src\\MusicStore\\MusicStore.csproj"); - - return true; - } - - private static void AddLinkerReference(string csproj) - { - var xdoc = XDocument.Load(csproj); - var ns = xdoc.Root.GetDefaultNamespace(); - bool added = false; - foreach (var el in xdoc.Root.Elements(ns + "ItemGroup")) - { - if (el.Elements(ns + "PackageReference").Any()) - { - el.Add(new XElement(ns + "PackageReference", - new XAttribute("Include", "ILLink.Tasks"), - new XAttribute("Version", "0.1.0-preview"))); - added = true; - break; - } - } - if (!added) - { - xdoc.Root.Add(new XElement(ns + "ItemGroup", - new XElement(ns + "PackageReference", - new XAttribute("Include", "ILLink.Tasks"), - new XAttribute("Version", "0.1.0-preview")))); - added = true; - } - using (var fs = new FileStream(csproj, FileMode.Create)) - { - xdoc.Save(fs); - } - } - - private static void RemoveCrossgenTarget(string csproj) - { - var xdoc = XDocument.Load(csproj); - var ns = xdoc.Root.GetDefaultNamespace(); - var target = xdoc.Root.Element(ns + "Target"); - target.Remove(); - using (var fs = new FileStream(csproj, FileMode.Create)) - { - xdoc.Save(fs); - } - } - private static void addMeasurement(ref ScenarioBenchmark scenario, string name, MetricModel metric, double value) { var iteration = new IterationModel diff --git a/tests/src/performance/linkbench/linkbench.csproj b/tests/src/performance/linkbench/linkbench.csproj index 2a3048ab21..46c79ff039 100644 --- a/tests/src/performance/linkbench/linkbench.csproj +++ b/tests/src/performance/linkbench/linkbench.csproj @@ -16,6 +16,7 @@ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> <DefineConstants>$(DefineConstants);STATIC</DefineConstants> <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker> + <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> @@ -23,8 +24,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> </PropertyGroup> <PropertyGroup> - <ProjectJson>..\project.json</ProjectJson> - <ProjectLockJson>..\project.lock.json</ProjectLockJson> + <RestoreOutputPath>..\obj</RestoreOutputPath> </PropertyGroup> <ItemGroup> <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> diff --git a/tests/src/performance/linkbench/scripts/build.cmd b/tests/src/performance/linkbench/scripts/build.cmd index 88b7eb139e..12f9f3f951 100644 --- a/tests/src/performance/linkbench/scripts/build.cmd +++ b/tests/src/performance/linkbench/scripts/build.cmd @@ -1,103 +1,141 @@ +setlocal ENABLEDELAYEDEXPANSION @echo off REM Usage: Build.cmd <LinkBench assets directory> setlocal -call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat" -set ROOT=%cd%\LinkBench set AssetDir=%1 set ExitCode=0 -mkdir LinkBench 2> nul -pushd %ROOT% +pushd %LinkBenchRoot% +set __CORFLAGS="%VS140COMNTOOLS%\..\..\..\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\CorFlags.exe" +if not exist %__CORFLAGS% ( + echo corflags.exe not found + exit /b -1 +) + +if defined __test_HelloWorld call :HelloWorld +if defined __test_WebAPI call :WebAPI +if defined __test_MusicStore call :MusicStore +if defined __test_MusicStore_R2R call :MusicStore_R2R +if defined __test_CoreFx call :CoreFx +if defined __test_Roslyn call :Roslyn + +popd +exit /b %ExitCode% + +:HelloWorld echo Build ** HelloWorld ** -cd %ROOT%\HelloWorld -dotnet restore -r win10-x64 -dotnet publish -c release -r win10-x64 -dotnet msbuild /t:Link /p:LinkerMode=sdk /p:RuntimeIdentifier=win10-x64 /v:n /p:Configuration=release +pushd %LinkBenchRoot%\HelloWorld +call %__dotnet2% restore -r win10-x64 +call %__dotnet2% publish -c release -r win10-x64 /p:LinkDuringPublish=false --output bin\release\netcoreapp2.0\win10-x64\Unlinked +call %__dotnet2% publish -c release -r win10-x64 --output bin\release\netcoreapp2.0\win10-x64\Linked if errorlevel 1 set ExitCode=1 -echo -- Done -- +popd +exit /b +:WebAPI echo Build ** WebAPI ** -cd %ROOT%\WebAPI -dotnet restore -r win10-x64 -dotnet publish -c release -r win10-x64 -dotnet msbuild /t:Link /p:LinkerMode=sdk /p:RuntimeIdentifier=win10-x64 /v:n /p:Configuration=release +pushd %LinkBenchRoot%\WebAPI +call %__dotnet2% restore -r win10-x64 +call %__dotnet2% publish -c release -r win10-x64 /p:LinkDuringPublish=false --output bin\release\netcoreapp2.0\win10-x64\unlinked +call %__dotnet2% publish -c release -r win10-x64 --output bin\release\netcoreapp2.0\win10-x64\linked if errorlevel 1 set ExitCode=1 -echo -- Done -- +popd +exit /b +:MusicStore echo Build ** MusicStore ** -cd %ROOT%\JitBench\src\MusicStore +pushd %LinkBenchRoot%\JitBench\src\MusicStore copy %AssetDir%\MusicStore\MusicStoreReflection.xml . -dotnet restore -r win10-x64 -dotnet publish -c release -r win10-x64 -dotnet msbuild /t:Link /p:LinkerMode=sdk /p:RuntimeIdentifier=win10-x64 /v:n /p:LinkerRootFiles=MusicStoreReflection.xml /p:Configuration=release +call %__dotnet2% restore -r win10-x64 +call %__dotnet2% publish -c release -r win10-x64 /p:LinkerRootDescriptors=MusicStoreReflection.xml /p:LinkDuringPublish=false --output bin\release\netcoreapp2.0\win10-x64\unlinked +call %__dotnet2% publish -c release -r win10-x64 /p:LinkerRootDescriptors=MusicStoreReflection.xml --output bin\release\netcoreapp2.0\win10-x64\linked if errorlevel 1 set ExitCode=1 -echo -- Done -- +popd +exit /b +:MusicStore_R2R +REM Since the musicstore benchmark has a workaround to use an old framework (to get non-crossgen'd packages), +REM we need to run crossgen on these assemblies manually for now. +REM Even once we have the linker running on R2R assemblies and remove this workaround, +REM we'll need a way to get the pre-crossgen assemblies for the size comparison. +REM We need to use it to crossgen the linked assemblies for the size comparison, +REM since the linker targets don't yet include a way to crossgen the linked assemblies. echo Build ** MusicStore Ready2Run ** -cd %ROOT%\JitBench\src\MusicStore +pushd %LinkBenchRoot%\JitBench\src\MusicStore +copy %AssetDir%\MusicStore\Get-Crossgen.ps1 powershell -noprofile -executionPolicy RemoteSigned -file Get-Crossgen.ps1 pushd bin\release\netcoreapp2.0\win10-x64\ -call :SetupR2R publish +mkdir R2R +call :SetupR2R unlinked if errorlevel 1 set ExitCode=1 call :SetupR2R linked if errorlevel 1 set ExitCode=1 -echo -- Done -- +popd +exit /b +:CoreFx echo Build ** CoreFX ** -cd %ROOT%\corefx +pushd %LinkBenchRoot%\corefx set BinPlaceILLinkTrimAssembly=true call build.cmd -release if errorlevel 1 set ExitCode=1 -echo -- Done -- +popd +exit /b +:Roslyn echo Build ** Roslyn ** -cd %ROOT%\roslyn -copy %AssetDir%\Roslyn\RoslynRoots.txt . -copy %AssetDir%\Roslyn\RoslynRoots.xml . -set RoslynRoot=%cd% -REM Build Roslyn -call restore.cmd -msbuild /m Roslyn.sln /p:Configuration=Release +pushd %LinkBenchRoot%\roslyn + REM Fetch ILLink -mkdir illink +if not exist illink mkdir illink cd illink -copy %AssetDir%\Roslyn\illinkcsproj illink.csproj -dotnet restore illink.csproj -r win10-x64 --packages bin +copy %AssetDir%\Roslyn\illinkcsproj illink.csproj +call %__dotnet1% restore --packages pkg +if errorlevel 1 set ExitCode=1 +set __IlLinkDll=%cd%\pkg\microsoft.netcore.illink\0.1.9-preview\lib\netcoreapp1.1\illink.dll cd .. + +REM Build CscCore +call Restore.cmd +cd src\Compilers\CSharp\CscCore +call %__dotnet1% publish -c Release -r win7-x64 +if errorlevel 1 set ExitCode=1 +REM Published CscCore to Binaries\Release\Exes\CscCore\win7-x64\publish +cd ..\..\..\.. + REM Create Linker Directory -cd Binaries\Release\Exes +cd Binaries\Release\Exes\CscCore\win7-x64\ mkdir Linked -cd CscCore + REM Copy Unmanaged Assets +cd publish FOR /F "delims=" %%I IN ('DIR /b *') DO ( - corflags %%I >nul 2> nul - if errorlevel 1 copy %%I ..\Linked >nul + %__CORFLAGS% %%I + if errorlevel 1 copy %%I ..\Linked ) copy *.ni.dll ..\Linked + REM Run Linker -dotnet %RoslynRoot%\illink\bin\illink.tasks\0.1.0-preview\tools\illink.dll -t -c link -a @%RoslynRoot%\RoslynRoots.txt -x %RoslynRoot%\RoslynRoots.xml -l none -out ..\Linked +call %__dotnet1% %__IlLinkDll% -t -c link -a @%AssetDir%\Roslyn\RoslynRoots.txt -x %AssetDir%\Roslyn\RoslynRoots.xml -l none -out ..\Linked if errorlevel 1 set ExitCode=1 -echo -- Done -- popd - -:Done -exit /b %ExitCode% +exit /b :SetupR2R REM Create R2R directory and copy all contents from MSIL to R2R directory -mkdir %1_r2r -xcopy /E /Y /Q %1 %1_r2r +mkdir R2R\%1 +xcopy /E /Y /Q %1 R2R\%1 REM Generate Ready2Run images for all MSIL files by running crossgen -cd %1_r2r -copy ..\..\..\..\..\crossgen.exe +pushd R2R\%1 +copy ..\..\..\..\..\..\crossgen.exe FOR /F %%I IN ('dir /b *.dll ^| find /V /I ".ni.dll" ^| find /V /I "System.Private.CoreLib" ^| find /V /I "mscorlib.dll"') DO ( REM Don't crossgen Corlib, since the native image already exists. REM For all other MSIL files (corflags returns 0), run crossgen - corflags %%I >nul 2>nul + %__CORFLAGS% %%I if not errorlevel 1 ( - crossgen /Platform_Assemblies_Paths . %%I >nul 2>nul + crossgen.exe /Platform_Assemblies_Paths . %%I if errorlevel 1 ( exit /b 1 ) @@ -112,5 +150,5 @@ FOR /F "delims=" %%I IN ('dir /b *.dll') DO ( ren %%~nI.ni.dll %%I ) ) -cd .. +popd exit /b 0 diff --git a/tests/src/performance/linkbench/scripts/clone.cmd b/tests/src/performance/linkbench/scripts/clone.cmd index ae28d41d08..60cfe202b6 100644 --- a/tests/src/performance/linkbench/scripts/clone.cmd +++ b/tests/src/performance/linkbench/scripts/clone.cmd @@ -1,30 +1,64 @@ +setlocal ENABLEDELAYEDEXPANSION @echo off -rmdir /s /q LinkBench +set EXITCODE=0 +pushd %LinkBenchRoot% -set ROOT=%cd%\LinkBench -mkdir LinkBench 2> nul -pushd %ROOT% +if not exist %__dotnet1% call :DotNet +if defined __test_HelloWorld call :HelloWorld +if defined __test_WebAPI call :WebAPI +if defined __test_MusicStore call :MusicStore +if defined __test_MusicStore_R2R call :MusicStore_R2R +if defined __test_CoreFx call :CoreFx +if defined __test_Roslyn call :Roslyn + +popd +exit /b %EXITCODE% + +:DotNet +REM Roslyn needs SDK 1.0.0, other benchmarks need SDK 2.0.0 +mkdir .Net1 +mkdir .Net2 +powershell -noprofile -executionPolicy RemoteSigned wget https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1 -OutFile dotnet-install.ps1 +powershell -noprofile -executionPolicy RemoteSigned -file dotnet-install.ps1 -InstallDir .Net1 +powershell -noprofile -executionPolicy RemoteSigned -file dotnet-install.ps1 -Channel master -InstallDir .Net2 -version 2.0.0-preview2-005905 +if not exist %__dotnet1% set EXITCODE=1&& echo DotNet.1.0.0 uninstalled +if not exist %__dotnet2% set EXITCODE=1&& echo DotNet.2.0.0 uninstalled +exit /b + +:HelloWorld mkdir HelloWorld cd HelloWorld -dotnet new console -if errorlevel 1 exit /b 1 +call %__dotnet2% new console +if errorlevel 1 set EXITCODE=1 cd .. +exit /b +:WebAPI mkdir WebAPI cd WebAPI -dotnet new webapi -if errorlevel 1 exit /b 1 +call %__dotnet2% new webapi +if errorlevel 1 set EXITCODE=1 cd .. +exit /b +:MusicStore git clone https://github.com/aspnet/JitBench -b dev -if errorlevel 1 exit /b 1 +if errorlevel 1 set EXITCODE=1 +exit /b +:MusicStore_R2R +REM MusicStore_R2R requires a previous MusicStore run. +REM No Additional Setup +exit /b + +:CoreFx git clone http://github.com/dotnet/corefx -if errorlevel 1 exit /b 1 +if errorlevel 1 set EXITCODE=1 +exit /b +:Roslyn git clone https://github.com/dotnet/roslyn.git -if errorlevel 1 exit /b 1 - -popd
\ No newline at end of file +if errorlevel 1 set EXITCODE=1 +exit /b |