You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+63-26Lines changed: 63 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,30 @@
1
-
# Performance testing extension for Unity Test Runner
1
+
# Performance testing extension for Unity Test Runner
2
2
3
3
Extension provides a set of calls to make it easier to take measurements and record profiler markers. It also collects data about build and player settings which is useful when comparing data for separating different hardware and configurations.
4
4
5
5
## Installing
6
-
To install this package, follow the instructions in the [Package Manager documentation](https://docs.unity3d.com/Packages/com.unity.package-manager-ui@latest/index.html).
6
+
To install this package, follow the instructions in the [Package Manager documentation](https://docs.unity3d.com/Packages/com.unity.package-manager-ui@latest/index.html).
7
7
8
8
And add `com.unity.test-framework.performance` your packages manifest.
If you are using 2018.1 or 2018.2 the module dependencies are unnecessary.
27
+
22
28
Assembly definitions should reference `Unity.PerformanceTesting` in order to use it. Create a new folder for storing tests in and then create a new asset from context menu called `right click/Create/Assembly definition`. In inspector for the assembly file check "Test Assemblies and apply. Then open the file in text editor and add `Unity.PerformanceTesting`.
23
29
24
30
```json
@@ -38,11 +44,10 @@ Assembly definitions should reference `Unity.PerformanceTesting` in order to use
38
44
}
39
45
```
40
46
41
-
More information on how to create and run tests please refer to [Unity Test Runner docs](https://docs.unity3d.com/Manual/testing-editortestsrunner.html).
42
-
43
-
## Saving results
47
+
How to test internals can be found in the following link:
If you are on 2018.3+ version of unity you can launch the editor with command line argument `-performanceTestResults "path"` it will save test results as json to path.
50
+
More information on how to create and run tests please refer to [Unity Test Runner docs](https://docs.unity3d.com/Manual/testing-editortestsrunner.html).
-**aggregationType** : Preferred aggregation (default is median)
72
+
-**aggregationType** : Preferred aggregation (default is median)
68
73
-**percentile** : If aggregationType is Percentile, the percentile value used for the aggregation. i.e 0.95.
69
74
-**threshold** : Threshold used for regression detection. If current sample value is over the threshold different from the baseline results, the result is concidered as a regression or a progression. Default value is 0.15f.
70
75
-**increaseIsBetter** : Defines if an increase in the measurement value is concidered as a progression (better) or a regression. Default is false.
@@ -73,11 +78,11 @@ If unspecified a default SampleGroupDefinition will be used with the name of "Me
73
78
74
79
## Taking measurements
75
80
76
-
Preferred way is to use `Measure.Method` or `Measure.Frames`. They both do a couple of warmup iterations which are then used to decide how many iterations should be measured. It is advised to keep measurements above 100 microseconds.
81
+
Preferred way is to use `Measure.Method` or `Measure.Frames`. They both do a couple of warmup iterations which are then used to decide how many iterations per measurement should be used.
In cases where you feel the default values are not ideal you can specify custom iterations.
96
+
97
+
WarmupCount - how many iterations to run without measuring for warmup
98
+
MeasurementCount - how many measurements to take
99
+
IterationsPerMeasurement - how many iterations per measurement to take
100
+
101
+
```
102
+
[PerformanceTest]
103
+
public void Test()
104
+
{
105
+
Measure.Method(() => { ... })
106
+
.WarmupCount(10)
107
+
.MeasurementCount(10)
108
+
.IterationsPerMeasurement(5)
109
+
.Run();
110
+
}
111
+
```
112
+
113
+
**FramesMeasurement Measure.Frames()**
91
114
92
-
Used to yield for a specified amount of frames. Records frame times.
115
+
Used to yield for frames. It will automatically select the number of warmup and runtime frames.
93
116
94
117
```csharp
95
118
[PerformanceUnityTest]
@@ -101,20 +124,34 @@ public IEnumerator Test()
101
124
}
102
125
```
103
126
104
-
In cases where you are measuring a system over frametime it is advised to disable frametime measurements and instead measure profiler systems markers.
127
+
In cases where you are measuring a system over frametime it is advised to disable frametime measurements and instead measure profiler markers for your system.
105
128
```csharp
106
129
[PerformanceUnityTest]
107
130
publicIEnumeratorTest()
108
131
{
109
132
...
110
133
111
-
// passing in false will run the frames but will not take frametime mesaurements
112
134
yieldreturnMeasure.Frames()
113
135
.ProfilerMarkers(...)
114
-
.Run(false);
136
+
.DontRecordFrametime()
137
+
.Run();
115
138
}
116
139
```
117
140
141
+
If you want more control, you can specify how many frames you want to measure.
142
+
143
+
```csharp
144
+
[PerformanceUnityTest]
145
+
publicIEnumeratorTest()
146
+
{
147
+
...
148
+
149
+
yieldreturnMeasure.Frames()
150
+
.WarmupCount(5)
151
+
.MeasurementCount(10)
152
+
.Run();
153
+
}
154
+
```
118
155
119
156
When method or frame measurements are not enough you can use the following to measure. It will measure Scope, Frames, Markers or Cusom.
120
157
@@ -157,9 +194,9 @@ Records profiler samples for a scope. The name of sample group definition has to
157
194
[PerformanceTest]
158
195
publicvoidTest()
159
196
{
160
-
SampleGroupDefinition[] m_definitions=
197
+
SampleGroupDefinition[] m_definitions=
161
198
{
162
-
newSampleGroupDefinition("Instantiate"),
199
+
newSampleGroupDefinition("Instantiate"),
163
200
newSampleGroupDefinition("Instantiate.Copy"),
164
201
newSampleGroupDefinition("Instantiate.Produce"),
165
202
newSampleGroupDefinition("Instantiate.Awake")
@@ -240,7 +277,7 @@ Each performance test will have a performance test summary. Every sample group w
240
277
241
278
```csharp
242
279
// Records total and frame times for loading a scene async
243
-
280
+
244
281
[PerformanceUnityTest]
245
282
publicIEnumeratorLoadAsync_SampleScene()
246
283
{
@@ -255,9 +292,9 @@ Each performance test will have a performance test summary. Every sample group w
0 commit comments