From c5322ac5d5742fd1ceee79e39de02f6ca28a16fc Mon Sep 17 00:00:00 2001 From: vis2k Date: Tue, 16 Mar 2021 12:40:26 +0800 Subject: [PATCH] remove performance test framework to fix CI (#2648) --- Assets/Mirror/Tests/Performance.meta | 8 -- Assets/Mirror/Tests/Performance/Editor.meta | 8 -- .../Editor/FakeNetworkConnection.cs | 24 ---- .../Editor/FakeNetworkConnection.cs.meta | 11 -- .../Mirror.Tests.Performance.Editor.asmdef | 30 ---- ...irror.Tests.Performance.Editor.asmdef.meta | 7 - .../Editor/NetworkWriterPerformance.cs | 71 ---------- .../Editor/NetworkWriterPerformance.cs.meta | 11 -- Assets/Mirror/Tests/Performance/README.md | 71 ---------- .../Mirror/Tests/Performance/README.md.meta | 7 - Assets/Mirror/Tests/Performance/Runtime.meta | 8 -- .../Mirror.Tests.Performance.Runtime.asmdef | 29 ---- ...rror.Tests.Performance.Runtime.asmdef.meta | 7 - .../Runtime/ULocalConnectionPerformance.cs | 129 ------------------ .../ULocalConnectionPerformance.cs.meta | 11 -- Packages/manifest.json | 1 - Packages/packages-lock.json | 10 -- 17 files changed, 443 deletions(-) delete mode 100644 Assets/Mirror/Tests/Performance.meta delete mode 100644 Assets/Mirror/Tests/Performance/Editor.meta delete mode 100644 Assets/Mirror/Tests/Performance/Editor/FakeNetworkConnection.cs delete mode 100644 Assets/Mirror/Tests/Performance/Editor/FakeNetworkConnection.cs.meta delete mode 100644 Assets/Mirror/Tests/Performance/Editor/Mirror.Tests.Performance.Editor.asmdef delete mode 100644 Assets/Mirror/Tests/Performance/Editor/Mirror.Tests.Performance.Editor.asmdef.meta delete mode 100644 Assets/Mirror/Tests/Performance/Editor/NetworkWriterPerformance.cs delete mode 100644 Assets/Mirror/Tests/Performance/Editor/NetworkWriterPerformance.cs.meta delete mode 100644 Assets/Mirror/Tests/Performance/README.md delete mode 100644 Assets/Mirror/Tests/Performance/README.md.meta delete mode 100644 Assets/Mirror/Tests/Performance/Runtime.meta delete mode 100644 Assets/Mirror/Tests/Performance/Runtime/Mirror.Tests.Performance.Runtime.asmdef delete mode 100644 Assets/Mirror/Tests/Performance/Runtime/Mirror.Tests.Performance.Runtime.asmdef.meta delete mode 100644 Assets/Mirror/Tests/Performance/Runtime/ULocalConnectionPerformance.cs delete mode 100644 Assets/Mirror/Tests/Performance/Runtime/ULocalConnectionPerformance.cs.meta diff --git a/Assets/Mirror/Tests/Performance.meta b/Assets/Mirror/Tests/Performance.meta deleted file mode 100644 index e83566019..000000000 --- a/Assets/Mirror/Tests/Performance.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e0b34ea3c905e3c42aaf95c1572edb1a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Tests/Performance/Editor.meta b/Assets/Mirror/Tests/Performance/Editor.meta deleted file mode 100644 index a4f42a1a9..000000000 --- a/Assets/Mirror/Tests/Performance/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2c40e1b4653f9ca4b928a0ff52f33c60 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Tests/Performance/Editor/FakeNetworkConnection.cs b/Assets/Mirror/Tests/Performance/Editor/FakeNetworkConnection.cs deleted file mode 100644 index 14a6d274c..000000000 --- a/Assets/Mirror/Tests/Performance/Editor/FakeNetworkConnection.cs +++ /dev/null @@ -1,24 +0,0 @@ -#if !UNITY_2019_2_OR_NEWER || UNITY_PERFORMANCE_TESTS_1_OR_OLDER -using System; - -namespace Mirror.Tests.Performance -{ - public class FakeNetworkConnection : NetworkConnectionToClient - { - public FakeNetworkConnection(int networkConnectionId) : base(networkConnectionId, false, 0) - { - } - - public override string address => "Test"; - - public override void Disconnect() - { - // nothing - } - - internal override void Send(ArraySegment segment, int channelId = 0) - { - } - } -} -#endif diff --git a/Assets/Mirror/Tests/Performance/Editor/FakeNetworkConnection.cs.meta b/Assets/Mirror/Tests/Performance/Editor/FakeNetworkConnection.cs.meta deleted file mode 100644 index 5532cd245..000000000 --- a/Assets/Mirror/Tests/Performance/Editor/FakeNetworkConnection.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 86a4aabfbe99daa45ad611feea5f959d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Tests/Performance/Editor/Mirror.Tests.Performance.Editor.asmdef b/Assets/Mirror/Tests/Performance/Editor/Mirror.Tests.Performance.Editor.asmdef deleted file mode 100644 index b0443e6d0..000000000 --- a/Assets/Mirror/Tests/Performance/Editor/Mirror.Tests.Performance.Editor.asmdef +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "Mirror.Tests.Performance.Editor", - "references": [ - "Unity.PerformanceTesting", - "Mirror", - "Mirror.Components", - "Mirror.Tests.Common" - ], - "optionalUnityReferences": [ - "TestAssemblies" - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [ - "UNITY_INCLUDE_TESTS" - ], - "versionDefines": [ - { - "name": "com.unity.test-framework.performance", - "expression": "(,2.0)", - "define": "UNITY_PERFORMANCE_TESTS_1_OR_OLDER" - } - ] -} \ No newline at end of file diff --git a/Assets/Mirror/Tests/Performance/Editor/Mirror.Tests.Performance.Editor.asmdef.meta b/Assets/Mirror/Tests/Performance/Editor/Mirror.Tests.Performance.Editor.asmdef.meta deleted file mode 100644 index 002753282..000000000 --- a/Assets/Mirror/Tests/Performance/Editor/Mirror.Tests.Performance.Editor.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 6ac82bd0f79158140826224aad56b5e3 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Tests/Performance/Editor/NetworkWriterPerformance.cs b/Assets/Mirror/Tests/Performance/Editor/NetworkWriterPerformance.cs deleted file mode 100644 index fb55a495f..000000000 --- a/Assets/Mirror/Tests/Performance/Editor/NetworkWriterPerformance.cs +++ /dev/null @@ -1,71 +0,0 @@ -#if !UNITY_2019_2_OR_NEWER || UNITY_PERFORMANCE_TESTS_1_OR_OLDER -using NUnit.Framework; -using UnityEngine; -using Unity.PerformanceTesting; - -namespace Mirror.Tests.Performance -{ - [Category("Performance")] - public class NetworkWriterPerformance - { - // A Test behaves as an ordinary method - [Test] -#if UNITY_2019_2_OR_NEWER - [Performance] -#else - [PerformanceTest] -#endif - public void RunWriteInt32() - { - Measure.Method(WriteInt32) - .WarmupCount(10) - .MeasurementCount(100) - .Run(); - } - - static void WriteInt32() - { - int count = 100000; - - // create big enough writer so we don't need to resize when testing - NetworkWriter writer = new NetworkWriter(); - writer.SetLength(count * 4); - writer.Position = 0; - - for (int i = 0; i < count; i++) - { - writer.WriteInt32(i); - } - } - // A Test behaves as an ordinary method - [Test] -#if UNITY_2019_2_OR_NEWER - [Performance] -#else - [PerformanceTest] -#endif - public void RunWriteQuaternion() - { - Measure.Method(WriteQuaternion) - .WarmupCount(10) - .MeasurementCount(100) - .Run(); - } - - static void WriteQuaternion() - { - int count = 100000; - - // create big enough writer so we don't need to resize when testing - NetworkWriter writer = new NetworkWriter(); - writer.SetLength(count * 16); - writer.Position = 0; - - for (int i = 0; i < count; i++) - { - writer.WriteQuaternion(Quaternion.identity); - } - } - } -} -#endif diff --git a/Assets/Mirror/Tests/Performance/Editor/NetworkWriterPerformance.cs.meta b/Assets/Mirror/Tests/Performance/Editor/NetworkWriterPerformance.cs.meta deleted file mode 100644 index 527576874..000000000 --- a/Assets/Mirror/Tests/Performance/Editor/NetworkWriterPerformance.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a3c833c30b262be45860a01b933a3220 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Tests/Performance/README.md b/Assets/Mirror/Tests/Performance/README.md deleted file mode 100644 index 690c6e4a6..000000000 --- a/Assets/Mirror/Tests/Performance/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# Performance Tests - -Performance tests require `com.unity.test-framework.performance` - -#### Install Unity Performance Testing Extension -When using 2019.1 or earlier you have to manually add these to your `manifest.json` or copy from Mirror's `Packages/manifest.json` - -- Open `manifest.json` -- Add -```json -{ - "dependencies": { - "com.unity.test-framework.performance": "0.1.50-preview", - "other dependencies here" - }, - "testables": [ - "com.unity.test-framework.performance" - ] -} -``` - -## Run Tests from CLI - -[Unity CLI Documentation](https://docs.unity3d.com/2018.4/Documentation/Manual/CommandLineArguments.html) - -Options: -- `-testResults` Where results are saved -- `-testPlatform` Use `editmode` or `playmode` to pick which tests to run -- `-testCategory` Comma separated list of test categories -- `-testsFilter` Comma separated list of test names -- `-logFile` change log path, Default path `%LOCALAPPDATA%\Unity\Editor\Editor.log` - -Example of running Benchmark tests from cli -``` -Unity.exe -testResults /path/to/send/results.xml -runTests -testPlatform playmode -projectPath G:\UnityProjects\Mirror -batchmode -testCategory Benchmark -``` - -## Create a Performance Benchmark Report - -To use Performance Benchmark Reporter you must have: - - [.NET core SDK](https://dotnet.microsoft.com/download) - - [Performance Benchmark Reporter DLL](https://github.com/Unity-Technologies/PerformanceBenchmarkReporter/releases) - - `test-framework.performance` Package at version `0.1.50` or earlier (available Unity versions 2018.3 or 2018.4) - -The Performance Benchmark Reporter does not work with newer versions of the test-framework because unity has modified the results XML. The Reporter is open source so it is possible to modify it to work with later versions at some point in the future. - - -### Run the Performance Benchmark Reporter - -1. Run the performance tests to create a `TestResults.xml` -2. If running from editor, move the generated `TestResults.xml` file -3. Change branches and run performance tests again -4. Once all results are collected run the Performance Benchmark Reporter DLL -5. Open the "UnityPerformanceBenchmark" html file that is created to view the report - -``` -dotnet UnityPerformanceBenchmarkReporter.dll --baseline=D:\UnityPerf\baseline.xml --results=D:\UnityPerf\results --reportdirpath=d:\UnityPerf -``` - - -## Links - -#### Blog post - - -#### Unity packages - - -#### Performance Benchmark Reporter - - \ No newline at end of file diff --git a/Assets/Mirror/Tests/Performance/README.md.meta b/Assets/Mirror/Tests/Performance/README.md.meta deleted file mode 100644 index e3f4ac931..000000000 --- a/Assets/Mirror/Tests/Performance/README.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: a322196416f669044b8d2fa186a6f80c -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Tests/Performance/Runtime.meta b/Assets/Mirror/Tests/Performance/Runtime.meta deleted file mode 100644 index 8375bb588..000000000 --- a/Assets/Mirror/Tests/Performance/Runtime.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5f902e7dc9ebba44fa9ed637a824ddb8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Tests/Performance/Runtime/Mirror.Tests.Performance.Runtime.asmdef b/Assets/Mirror/Tests/Performance/Runtime/Mirror.Tests.Performance.Runtime.asmdef deleted file mode 100644 index 45a77bfa9..000000000 --- a/Assets/Mirror/Tests/Performance/Runtime/Mirror.Tests.Performance.Runtime.asmdef +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "Mirror.Tests.Performance.Runtime", - "references": [ - "Unity.PerformanceTesting", - "Mirror", - "Mirror.Components", - "Mirror.Tests.Common", - "Mirror.Examples" - ], - "optionalUnityReferences": [ - "TestAssemblies" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [ - "UNITY_INCLUDE_TESTS" - ], - "versionDefines": [ - { - "name": "com.unity.test-framework.performance", - "expression": "(,2.0)", - "define": "UNITY_PERFORMANCE_TESTS_1_OR_OLDER" - } - ] -} \ No newline at end of file diff --git a/Assets/Mirror/Tests/Performance/Runtime/Mirror.Tests.Performance.Runtime.asmdef.meta b/Assets/Mirror/Tests/Performance/Runtime/Mirror.Tests.Performance.Runtime.asmdef.meta deleted file mode 100644 index d146fe575..000000000 --- a/Assets/Mirror/Tests/Performance/Runtime/Mirror.Tests.Performance.Runtime.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 98f4e20eb641b974bab6c080624bb1ae -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Tests/Performance/Runtime/ULocalConnectionPerformance.cs b/Assets/Mirror/Tests/Performance/Runtime/ULocalConnectionPerformance.cs deleted file mode 100644 index afb7bef20..000000000 --- a/Assets/Mirror/Tests/Performance/Runtime/ULocalConnectionPerformance.cs +++ /dev/null @@ -1,129 +0,0 @@ -#if !UNITY_2019_2_OR_NEWER || UNITY_PERFORMANCE_TESTS_1_OR_OLDER -using System.Collections; -using NUnit.Framework; -using Unity.PerformanceTesting; -using UnityEngine; -using UnityEngine.TestTools; - - -namespace Mirror.Tests.Performance.Runtime -{ - class NetworkManagerTest : NetworkManager - { - public override void Awake() - { - transport = gameObject.AddComponent(); - playerPrefab = new GameObject(); - NetworkIdentity identity = playerPrefab.AddComponent(); - identity.assetId = System.Guid.NewGuid(); - base.Awake(); - } - public override void OnDestroy() - { - base.OnDestroy(); - - // clean up new object created in awake - Destroy(playerPrefab); - } - } - [Category("Performance")] - public class ULocalConnectionPerformance - { - NetworkManager manager; - - IEnumerator SetUpConnections() - { - GameObject go = new GameObject(); - manager = go.AddComponent(); - yield return null; - - manager.StartHost(); - - yield return null; - } - IEnumerator Disconnect() - { - manager.StopHost(); - yield return null; - GameObject.Destroy(manager.gameObject); - } - [OneTimeTearDown] - public void OneTimeTearDown() - { - if (NetworkManager.singleton != null) - { - GameObject go = NetworkManager.singleton.gameObject; - NetworkManager.Shutdown(); - GameObject.DestroyImmediate(go); - } - } - - [UnityTest] - public IEnumerator ConnectAndDisconnectWorks() - { - yield return SetUpConnections(); - - yield return Disconnect(); - } - [UnityTest] -#if UNITY_2019_2_OR_NEWER - [Performance] -#else - [PerformanceUnityTest] -#endif - public IEnumerator ULocalConnectionPerformanceWithEnumeratorPasses() - { - yield return SetUpConnections(); - - using (Measure.Frames() - .WarmupCount(10) - .MeasurementCount(100) - .Scope()) - { - for (int i = 0; i < 100; i++) - { - sendSomeMessages(); - yield return null; - } - } - - yield return Disconnect(); - } - - static void sendSomeMessages() - { - for (uint i = 0; i < 10000u; i++) - { - using (PooledNetworkWriter writer = NetworkWriterPool.GetWriter()) - { - // write mask - writer.WriteUInt64(1); - // behaviour length - writer.WriteInt32(1); - - // behaviour delta - - // sync object mask - writer.WriteUInt64(0); - // sync object delta - // assume no sync objects for this test - - // sync var mask - writer.WriteUInt64(1); - // sync var delta - // assume sync var has changed its value to 10 - writer.WriteInt32(10); - - - // send message - NetworkServer.localConnection.Send(new UpdateVarsMessage - { - netId = i, - payload = writer.ToArraySegment() - }); - } - } - } - } -} -#endif diff --git a/Assets/Mirror/Tests/Performance/Runtime/ULocalConnectionPerformance.cs.meta b/Assets/Mirror/Tests/Performance/Runtime/ULocalConnectionPerformance.cs.meta deleted file mode 100644 index 2cb537f9b..000000000 --- a/Assets/Mirror/Tests/Performance/Runtime/ULocalConnectionPerformance.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 82f7edc4e79efb74db284b02dab6704d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/manifest.json b/Packages/manifest.json index 1d079e509..6a79f2643 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -5,7 +5,6 @@ "com.unity.ide.rider": "1.1.4", "com.unity.ide.vscode": "1.2.3", "com.unity.test-framework": "1.1.22", - "com.unity.test-framework.performance": "2.7.0-preview", "com.unity.textmeshpro": "2.0.1", "com.unity.timeline": "1.2.6", "com.unity.ugui": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 389995524..b275915d4 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -46,16 +46,6 @@ }, "url": "https://packages.unity.com" }, - "com.unity.test-framework.performance": { - "version": "2.7.0-preview", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.test-framework": "1.1.0", - "com.unity.modules.jsonserialize": "1.0.0" - }, - "url": "https://packages.unity.com" - }, "com.unity.textmeshpro": { "version": "2.0.1", "depth": 0,