mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
remove performance test framework to fix CI (#2648)
This commit is contained in:
parent
53dad15e04
commit
c5322ac5d5
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: e0b34ea3c905e3c42aaf95c1572edb1a
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 2c40e1b4653f9ca4b928a0ff52f33c60
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -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<byte> segment, int channelId = 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 86a4aabfbe99daa45ad611feea5f959d
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 6ac82bd0f79158140826224aad56b5e3
|
|
||||||
AssemblyDefinitionImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -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
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a3c833c30b262be45860a01b933a3220
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -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
|
|
||||||
<https://blogs.unity3d.com/2018/09/25/performance-benchmarking-in-unity-how-to-get-started/>
|
|
||||||
|
|
||||||
#### Unity packages
|
|
||||||
<https://docs.unity3d.com/Packages/com.unity.test-framework.performance@0.1/manual/index.html>
|
|
||||||
|
|
||||||
#### Performance Benchmark Reporter
|
|
||||||
|
|
||||||
<https://github.com/Unity-Technologies/PerformanceBenchmarkReporter/wiki>
|
|
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a322196416f669044b8d2fa186a6f80c
|
|
||||||
TextScriptImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 5f902e7dc9ebba44fa9ed637a824ddb8
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 98f4e20eb641b974bab6c080624bb1ae
|
|
||||||
AssemblyDefinitionImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -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<MemoryTransport>();
|
|
||||||
playerPrefab = new GameObject();
|
|
||||||
NetworkIdentity identity = playerPrefab.AddComponent<NetworkIdentity>();
|
|
||||||
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<NetworkManagerTest>();
|
|
||||||
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
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 82f7edc4e79efb74db284b02dab6704d
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -5,7 +5,6 @@
|
|||||||
"com.unity.ide.rider": "1.1.4",
|
"com.unity.ide.rider": "1.1.4",
|
||||||
"com.unity.ide.vscode": "1.2.3",
|
"com.unity.ide.vscode": "1.2.3",
|
||||||
"com.unity.test-framework": "1.1.22",
|
"com.unity.test-framework": "1.1.22",
|
||||||
"com.unity.test-framework.performance": "2.7.0-preview",
|
|
||||||
"com.unity.textmeshpro": "2.0.1",
|
"com.unity.textmeshpro": "2.0.1",
|
||||||
"com.unity.timeline": "1.2.6",
|
"com.unity.timeline": "1.2.6",
|
||||||
"com.unity.ugui": "1.0.0",
|
"com.unity.ugui": "1.0.0",
|
||||||
|
@ -46,16 +46,6 @@
|
|||||||
},
|
},
|
||||||
"url": "https://packages.unity.com"
|
"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": {
|
"com.unity.textmeshpro": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user