Update perflab tests to execute in a fixed order
authorAndy Ayers <andya@microsoft.com>
Wed, 10 Jan 2018 00:25:22 +0000 (16:25 -0800)
committerAndy Ayers <andya@microsoft.com>
Thu, 18 Jan 2018 16:44:34 +0000 (08:44 -0800)
Goal is to pin class init overhead on one test consistently. Also we were
not picking up the "optimize for benchmark" attribute and so likely risking
having tests execute concurrently.

tests/src/performance/perflab/PerfLab.csproj
tests/src/performance/perflab/Properties/AssemblyInfo.cs [deleted file]
tests/src/performance/perflab/XunitPerformance.cs [new file with mode: 0644]

index ccacb0b..f295d94 100644 (file)
@@ -37,6 +37,7 @@
     <Compile Include="ReflectionPerf.cs" />
     <Compile Include="StackWalk.cs" />
     <Compile Include="ThreadingPerf.cs" />
+    <Compile Include="XunitPerformance.cs" />
   </ItemGroup>
   <ItemGroup>
     <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
diff --git a/tests/src/performance/perflab/Properties/AssemblyInfo.cs b/tests/src/performance/perflab/Properties/AssemblyInfo.cs
deleted file mode 100644 (file)
index b4d55dc..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-using Microsoft.Xunit.Performance;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("PerfLabTests")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("PerfLabTests")]
-[assembly: AssemblyCopyright("Copyright \u00A9  2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("8761596f-209c-4277-a6ab-b7696ecf8f30")]
-
-// Version information for an assembly consists of the following four values:
-//
-//      Major Version
-//      Minor Version 
-//      Build Number
-//      Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers 
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
-
-[assembly: OptimizeForBenchmarks]
\ No newline at end of file
diff --git a/tests/src/performance/perflab/XunitPerformance.cs b/tests/src/performance/perflab/XunitPerformance.cs
new file mode 100644 (file)
index 0000000..72e99f8
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using Microsoft.Xunit.Performance;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Xunit;
+using Xunit.Abstractions;
+using Xunit.Sdk;
+
+[assembly: OptimizeForBenchmarks]
+
+// Constrain tests to execute in a predetermined order
+[assembly: TestCaseOrderer("PerfLabTests.DisplayNameTestCaseOrderer", "PerfLab")]
+
+namespace PerfLabTests
+{
+
+    public class DisplayNameTestCaseOrderer : ITestCaseOrderer
+    {
+        public IEnumerable<TTestCase> OrderTestCases<TTestCase>(IEnumerable<TTestCase> testCases)
+        where TTestCase : ITestCase
+        => testCases.OrderBy(test => test.DisplayName);
+    }
+
+}