Skip to content

Commit

Permalink
Convert JIT/Performance to a merged test group (#85851)
Browse files Browse the repository at this point in the history
See https://github.com/markples/utils/tree/for-PR-dotnet-runtime-85847-others for ILTransform tool.

* Manual removal of C# Main args
* [ILTransform -prociso] Set RequiresProcessIsolation when needed by other properties
* [ILTransform -public] Make test entrypoints accessible
* [ILTransform -ilfact] Main->TestEntryPoint, [Fact], remove OutputType=Exe
* Manual fixes for xUnit1013 - internal methods, disable for region
* Add merged group
  • Loading branch information
markples committed May 12, 2023
1 parent 5fabb48 commit a8947cc
Show file tree
Hide file tree
Showing 202 changed files with 502 additions and 432 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,25 @@ contributed by Marek Safar
*/

using System;
using System.Runtime.CompilerServices;
using Xunit;

namespace BenchmarksGame
{
public class BinaryTrees_2
{
const int minDepth = 4;

public static int Main(String[] args)
[Fact]
public static int TestEntryPoint()
{
int n = 0;
if (args.Length > 0) n = Int32.Parse(args[0]);
return Test(null);
}

[MethodImpl(MethodImplOptions.NoInlining)]
public static int Test(int? arg)
{
int n = arg ?? 0;

int check = Bench(n, true);
int expected = 4398;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for GCStressIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<GCStressIncompatible>true</GCStressIncompatible>
</PropertyGroup>
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,24 @@ minor improvements by Alex Yakunin
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Xunit;

namespace BenchmarksGame
{
public class BinaryTrees_5
{
public const int MinDepth = 4;

public static int Main(string[] args)
[Fact]
public static int TestEntryPoint()
{
var n = args.Length == 0 ? 0 : int.Parse(args[0]);
return Test(null);
}

[MethodImpl(MethodImplOptions.NoInlining)]
public static int Test(int? arg)
{
var n = arg ?? 0;

int check = Bench(n, true);
int expected = 4398;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for GCStressIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<GCStressIncompatible>true</GCStressIncompatible>
</PropertyGroup>
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Xunit;
//using BenchmarkDotNet.Attributes;
//using MicroBenchmarks;

Expand All @@ -33,9 +34,16 @@ public class BinaryTrees_6
// 21 is used in official numbers; about 7.8s
const int N = 18;

public static int Main(string[] args)
[Fact]
public static int TestEntryPoint()
{
var n = args.Length == 0 ? 0 : int.Parse(args[0]);
return Test(null);
}

[MethodImpl(MethodImplOptions.NoInlining)]
public static int Test(int? arg)
{
var n = arg ?? 0;
int check = Bench(n, true);

const int expected = 4398;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for GCStressIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<GCStressIncompatible>true</GCStressIncompatible>
</PropertyGroup>
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/

using System;
using System.Runtime.CompilerServices;
using Xunit;

namespace BenchmarksGame
{
Expand Down Expand Up @@ -71,9 +73,16 @@ public int[] fannkuch(int n)
} while (true);
}

static int Main(string[] args)
[Fact]
public static int TestEntryPoint()
{
int n = (args.Length > 0) ? Int32.Parse(args[0]) : 7;
return Test(null);
}

[MethodImpl(MethodImplOptions.NoInlining)]
static int Test(int? arg)
{
int n = arg ?? 7;
var fr2 = new FannkuchRedux_2();
var pf = fr2.fannkuch(n);
Console.Write("{0}\nPfannkuchen({1}) = {2}\n", pf[0], n, pf[1]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ parallel and small optimisations by Anthony Lloyd
using System;
using System.Threading;
using System.Runtime.CompilerServices;
using Xunit;

namespace BenchmarksGame
{
Expand Down Expand Up @@ -98,9 +99,16 @@ static void run(int n, int taskId, int taskSize)
maxFlips[taskId] = maxflips;
}

public static int Main(string[] args)
[Fact]
public static int TestEntryPoint()
{
int n = args.Length > 0 ? int.Parse(args[0]) : 7;
return Test(null);
}

[MethodImpl(MethodImplOptions.NoInlining)]
static int Test(int? arg)
{
int n = arg ?? 7;
int sum = Bench(n, true);

int expected = 16;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using Xunit;
//using BenchmarkDotNet.Attributes;
//using MicroBenchmarks;

Expand All @@ -23,9 +24,16 @@ namespace BenchmarksGame
//[BenchmarkCategory(Categories.Runtime, Categories.BenchmarksGame, Categories.JIT)]
public unsafe class FannkuchRedux_9
{
public static int Main(string[] args)
[Fact]
public static int TestEntryPoint()
{
int n = args.Length > 0 ? int.Parse(args[0]) : 7;
return Test(null);
}

[MethodImpl(MethodImplOptions.NoInlining)]
static int Test(int? arg)
{
int n = arg ?? 7;
int sum = Bench(n, true);

int expected = 228;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ modified by Josh Goldfoot (fasta-repeat buffering)
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Xunit;

namespace BenchmarksGame
{
Expand All @@ -35,9 +36,16 @@ public class Fasta_1
const int IC = 29573;
static int seed = 42;

public static int Main(string[] args)
[Fact]
public static int TestEntryPoint()
{
int n = args.Length > 0 ? Int32.Parse(args[0]) : 1000;
return Test(null);
}

[MethodImpl(MethodImplOptions.NoInlining)]
static int Test(int? arg)
{
int n = arg ?? 1000;

Bench(n, true);
return 100;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,24 @@ optimizations by Alp Toker <[email protected]>

using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using Xunit;

namespace BenchmarksGame
{
public class Fasta_2
{
static int Main(string[] args)
[Fact]
public static int TestEntryPoint()
{
int n = args.Length > 0 ? Int32.Parse(args[0]) : 1000;
return Test(null);
}

[MethodImpl(MethodImplOptions.NoInlining)]
static int Test(int? arg)
{
int n = arg ?? 1000;

Bench(n, true);
return 100;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.IO;
using System.Collections.Generic;
using System.Text;
using Xunit;

namespace BenchmarksGame
{
Expand Down Expand Up @@ -81,7 +82,8 @@ public static byte[] GetBytes(this List<string> input)
public class KNucleotide_1
{

public static int Main()
[Fact]
public static int TestEntryPoint()
{
var helpers = new TestHarnessHelpers(bigInput: false);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ submitted by Josh Goldfoot
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using Xunit;

namespace BenchmarksGame
{
Expand Down Expand Up @@ -252,7 +253,8 @@ static string writeCount(Dictionary<long, Wrapper> dictionary, string fragment,
return string.Concat(n.ToString(), "\t", fragment);
}

public static int Main()
[Fact]
public static int TestEntryPoint()
{
var helpers = new TestHarnessHelpers(bigInput: false);
bool ok = Bench(helpers, true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,24 @@

using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using Xunit;

namespace BenchmarksGame
{
public class Mandelbrot_2
{
public static int Main(String[] args)
[Fact]
public static int TestEntryPoint()
{
int width = 80;
if (args.Length > 0)
width = Int32.Parse(args[0]);
return Test(null);
}

[MethodImpl(MethodImplOptions.NoInlining)]
static int Test(int? arg)
{
int width = arg ?? 80;

int lineLen = (width - 1) / 8 + 1;
var bytes = new byte[width * lineLen];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
Expand Down
Loading

0 comments on commit a8947cc

Please sign in to comment.