Skip to content

Commit ee66a84

Browse files
author
Unity Technologies
committed
com.unity.test-framework.performance@3.0.0-pre.2
## [3.0.0-pre.2] - 2023-04-06 ### Added - Help button, which redirects the user to documentation website - Clear Results button, which clears all Performance test results - Updated CI to support more Unity versions and expand test coverage ### Changed - Updated the style of toolbar buttons to match that of the Test Runner window for consistency - Export button is now disabled instead of hidden when there are no Performance test results - Made AutoRefresh toggle retain its state after closing and reopening the window - Moved the Performance Test Report from 'Window/Analysis' to 'Window/General' near Test Runner for better accessibility ### Removed - Build project from CI ### Fixed - Issue where running tests with the Test Report window open would cause the error message "The object of type 'Material' has been destroyed" to appear - Issues where incorrect labels were displayed at certain scenarios - Issues flagged by SonarQube
1 parent d12c954 commit ee66a84

File tree

15 files changed

+262
-167
lines changed

15 files changed

+262
-167
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Changelog
22

3+
## [3.0.0-pre.2] - 2023-04-06
4+
### Added
5+
- Help button, which redirects the user to documentation website
6+
- Clear Results button, which clears all Performance test results
7+
- Updated CI to support more Unity versions and expand test coverage
8+
### Changed
9+
- Updated the style of toolbar buttons to match that of the Test Runner window for consistency
10+
- Export button is now disabled instead of hidden when there are no Performance test results
11+
- Made AutoRefresh toggle retain its state after closing and reopening the window
12+
- Moved the Performance Test Report from 'Window/Analysis' to 'Window/General' near Test Runner for better accessibility
13+
### Removed
14+
- Build project from CI
15+
### Fixed
16+
- Issue where running tests with the Test Report window open would cause the error message "The object of type 'Material' has been destroyed" to appear
17+
- Issues where incorrect labels were displayed at certain scenarios
18+
- Issues flagged by SonarQube
19+
320
## [3.0.0-pre.1] - 2023-03-02
421
### Added
522
- Merged 2.8.1 changes that weren't reflected in 2.10.0 release

Documentation~/index.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ Install the Performance Testing Extension package using one of the following met
1515

1616
Example:
1717
1. Open the `manifest.json` file for your Unity project (located in the YourProject/Packages directory) in a text editor.
18-
2. Add `"com.unity.test-framework.performance": "2.11.0-pre.1",` to the dependencies.
18+
2. Add `"com.unity.test-framework.performance": "3.0.0-pre.2",` to the dependencies.
1919
3. Save the manifest.json file.
2020
4. Verify the Performance Testing Extension is now installed by opening the Unity Package Manager window.
2121

2222
When the package is installed, add a reference to `Unity.PerformanceTesting` in your assembly definition to access the performance testing APIs.
2323

2424
## Unity version compatibility
2525

26-
Unity releases can often include changes that break compatibility with the Performance Testing Extension, so we cannot currently guarantee latest package version compatability with every Unity version. The table below shows which version of the package is compatible with which Unity release streams.
26+
Unity releases can often include changes that break compatibility with the Performance Testing Extension, so we cannot currently guarantee latest package version compatability with every Unity version. The table below shows which version of the package is compatible with which Unity release streams.
2727

2828
| Unity stream | Package version |
29-
| ------------------------- | -------------- |
30-
| 2023.2 | 3.0.0-pre.1 |
31-
| 2023.1 | 3.0.0-pre.1 |
32-
| 2022.2 | 3.0.0-pre.1 |
33-
| 2022.1 | 3.0.0-pre.1 |
34-
| 2021.3 | 3.0.0-pre.1 |
35-
| 2020.3 | 3.0.0-pre.1 |
36-
| 2019.4 | 2.8.1-preview |
29+
| ------------------------- |-----------------|
30+
| 2023.2 | 3.0.0-pre.2 |
31+
| 2023.1 | 3.0.0-pre.2 |
32+
| 2022.2 | 3.0.0-pre.2 |
33+
| 2022.1 | 3.0.0-pre.2 |
34+
| 2021.3 | 3.0.0-pre.2 |
35+
| 2020.3 | 3.0.0-pre.2 |
36+
| 2019.4 | 2.8.1-preview |
3737

3838
## Tips
3939

Editor/PerformanceTestRunSaver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void ICallbacks.RunStarted(ITestAdaptor testsToRun)
2929

3030
void ICallbacks.RunFinished(ITestResultAdaptor result)
3131
{
32-
PlayerCallbacks.saved = false;
32+
PlayerCallbacks.Saved = false;
3333

3434
try
3535
{

Editor/TestReportGraph/TestReportWindow.cs

Lines changed: 118 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal class TestReportWindow : EditorWindow
3333
private bool m_NewerFileExists = false;
3434
private double m_LastFileCheckTime = 0f;
3535
private float m_FileCheckFrequencySeconds = 3f;
36-
private bool m_AutoRefresh = false;
36+
private bool m_AutoRefresh;
3737

3838
private List<string> m_sampleGroups = new List<string>();
3939

@@ -109,7 +109,7 @@ public void SelectTest(PerformanceTestResult result)
109109
}
110110
}
111111

112-
[MenuItem("Window/Analysis/Performance Test Report")]
112+
[MenuItem("Window/General/Performance Test Report", false, priority = 202)]
113113
private static void Init()
114114
{
115115
var window = GetWindow<TestReportWindow>("Test Report");
@@ -118,12 +118,11 @@ private static void Init()
118118
window.Show();
119119
}
120120

121-
public bool CheckAndSetupMaterial()
121+
public void SetupMaterial()
122122
{
123-
// Check if the material has already been created. If not, create a new material.
124-
m_material ??= new Material(Shader.Find("Unlit/TestReportShader"));
125-
// Check if the material is not null and return the result.
126-
return !System.Object.Equals(m_material, null);
123+
// Create a new material
124+
m_material = new Material(Shader.Find("Unlit/TestReportShader"));
125+
m_material.SetPass(0);
127126
}
128127

129128
private string GetResultsPath()
@@ -207,7 +206,7 @@ private void LoadData()
207206

208207
private void OnEnable()
209208
{
210-
CheckAndSetupMaterial();
209+
SetupMaterial();
211210

212211
LoadData();
213212
}
@@ -363,137 +362,153 @@ private void Export()
363362
}
364363
}
365364
}
365+
366+
private void ClearResults()
367+
{
368+
File.Delete(GetResultsPath());
369+
m_resultsData = null;
370+
GUILayout.Label(string.Empty);
371+
}
366372

367373
private void Draw()
368374
{
369-
GUIStyle selectedStyle = new GUIStyle(GUI.skin.label);
370-
selectedStyle.fontStyle = FontStyle.Bold;
375+
var isResultsCountPositive = m_resultsData?.Results.Count > 0;
371376

372377
GUILayout.BeginHorizontal();
378+
m_AutoRefresh = EditorPrefs.GetBool("ToggleState", false);
373379
m_AutoRefresh = GUILayout.Toggle(m_AutoRefresh, "Auto Refresh");
374380
if (GUILayout.Button("Refresh", GUILayout.Width(100)))
375381
Refresh();
376-
GUILayout.Label(string.Format("Last results {0}", m_lastResultsDateTime));
382+
EditorPrefs.SetBool("ToggleState", m_AutoRefresh);
383+
377384
if (m_NewerFileExists)
378385
{
379386
if (m_AutoRefresh)
380387
Refresh();
381388
else
382-
GUILayout.Label(" - New data available");
389+
GUILayout.Label("New data available");
383390
}
391+
384392
GUILayout.FlexibleSpace();
385-
if (m_resultsData != null && m_resultsData.Results.Count > 0)
386-
{
387-
if (GUILayout.Button("Export", GUILayout.Width(100)))
393+
394+
if (isResultsCountPositive) GUILayout.Label($"Last results {m_lastResultsDateTime}");
395+
GUI.enabled = isResultsCountPositive;
396+
if (GUILayout.Button("Clear Results", GUILayout.Width(100)) && EditorUtility.DisplayDialog(
397+
"Clear Results", "Are you sure you want to clear all Performance test results?", "Clear", "Cancel"))
398+
ClearResults();
399+
if (GUILayout.Button("Export", GUILayout.Width(100)))
388400
Export();
389-
}
401+
GUI.enabled = true;
402+
390403
GUILayout.EndHorizontal();
391404

392-
if (m_resultsData == null)
405+
if (m_resultsData == null || !isResultsCountPositive)
406+
{
407+
GUILayout.Label(m_NewerFileExists ? string.Empty : "No performance test data found");
393408
return;
409+
}
394410

395-
if (m_resultsData.Results.Count <= 0)
396-
GUILayout.Label("No performance test data found.");
397-
else
411+
m_showTests = BoldFoldout(m_showTests, "Test View");
412+
if (m_showTests)
398413
{
399-
m_showTests = BoldFoldout(m_showTests, "Test View");
400-
if (m_showTests)
414+
if (m_testListTable != null)
401415
{
402-
if (m_testListTable != null)
403-
{
404-
Rect r = GUILayoutUtility.GetRect(position.width, m_testListHeight, GUI.skin.box,
405-
GUILayout.ExpandWidth(true));
406-
m_testListTable.OnGUI(r);
407-
Resize(r.y);
408-
}
416+
Rect r = GUILayoutUtility.GetRect(position.width, m_testListHeight, GUI.skin.box,
417+
GUILayout.ExpandWidth(true));
418+
m_testListTable.OnGUI(r);
419+
Resize(r.y);
409420
}
421+
}
410422

411-
if (!string.IsNullOrEmpty(m_selectedTest))
423+
if (!string.IsNullOrEmpty(m_selectedTest))
424+
{
425+
var profileDataFile = Path.Combine(Application.persistentDataPath,
426+
Utils.RemoveIllegalCharacters(m_selectedTest) + ".raw");
427+
if (File.Exists(profileDataFile))
412428
{
413-
var profileDataFile = Path.Combine(Application.persistentDataPath,
414-
Utils.RemoveIllegalCharacters(m_selectedTest) + ".raw");
415-
if (File.Exists(profileDataFile))
429+
if (GUILayout.Button(string.Format("Load profiler data for test: {0}", m_selectedTest)))
416430
{
417-
if (GUILayout.Button(string.Format("Load profiler data for test: {0}", m_selectedTest)))
418-
{
419-
ProfilerDriver.LoadProfile(profileDataFile, false);
420-
}
431+
ProfilerDriver.LoadProfile(profileDataFile, false);
421432
}
422433
}
434+
}
423435

424-
m_showSamples = BoldFoldout(m_showSamples, "Sample Group View");
425-
if (m_showSamples)
436+
m_showSamples = BoldFoldout(m_showSamples, "Sample Group View");
437+
if (m_showSamples)
438+
{
439+
SetColumnSizes(50, 50, 50, 50);
440+
441+
EditorGUILayout.BeginVertical();
442+
m_sampleGroupScroll =
443+
EditorGUILayout.BeginScrollView(m_sampleGroupScroll, false,
444+
true); //, false, false, GUIStyle.none, GUI.skin.verticalScrollbar, GUI.skin.window);
445+
int dataIndex = 0;
446+
foreach (var result in m_resultsData.Results)
426447
{
427-
SetColumnSizes(50, 50, 50, 50);
448+
if (result.Name != m_selectedTest)
449+
{
450+
dataIndex += result.SampleGroups.Count;
451+
continue;
452+
}
428453

429-
EditorGUILayout.BeginVertical();
430-
m_sampleGroupScroll =
431-
EditorGUILayout.BeginScrollView(m_sampleGroupScroll, false,
432-
true); //, false, false, GUIStyle.none, GUI.skin.verticalScrollbar, GUI.skin.window);
433-
int dataIndex = 0;
434-
foreach (var result in m_resultsData.Results)
454+
foreach (var sampleGroup in result.SampleGroups)
435455
{
436-
if (result.Name != m_selectedTest)
456+
var data = m_sampleGroupAdditionalData[dataIndex];
457+
dataIndex++;
458+
var samplesToDraw = sampleGroup.Samples;
459+
float min = data.min;
460+
float lowerQuartile = data.lowerQuartile;
461+
float median = data.median;
462+
float upperQuartile = data.upperQuartile;
463+
float max = data.max;
464+
465+
float graphMin = min > 0.0f ? 0.0f : min;
466+
467+
EditorGUILayout.BeginVertical(GUI.skin.box,
468+
GUILayout.Width(position.width - GUI.skin.verticalScrollbar.fixedWidth -
469+
(GUI.skin.box.padding.horizontal + GUI.skin.box.margin.horizontal)),
470+
GUILayout.ExpandHeight(false));
471+
EditorGUILayout.LabelField(sampleGroup.Name, m_boldStyle);
472+
EditorGUILayout.LabelField("Sample Unit: " + sampleGroup.Unit.ToString());
473+
if (samplesToDraw.Count > m_chartLimit)
437474
{
438-
dataIndex += result.SampleGroups.Count;
439-
continue;
475+
string message =
476+
string.Format(
477+
"Sample Group has more than {0} Samples. The first {0} Samples will be displayed. However, calculations are done according to the all samples received from the test run.",
478+
m_chartLimit);
479+
EditorGUILayout.HelpBox(message, MessageType.Warning, true);
480+
samplesToDraw = samplesToDraw.Take(m_chartLimit).ToList();
440481
}
441482

442-
foreach (var sampleGroup in result.SampleGroups)
443-
{
444-
var data = m_sampleGroupAdditionalData[dataIndex];
445-
dataIndex++;
446-
var samplesToDraw = sampleGroup.Samples;
447-
float min = data.min;
448-
float lowerQuartile = data.lowerQuartile;
449-
float median = data.median;
450-
float upperQuartile = data.upperQuartile;
451-
float max = data.max;
452-
453-
float graphMin = min > 0.0f ? 0.0f : min;
454-
455-
EditorGUILayout.BeginVertical(GUI.skin.box,
456-
GUILayout.Width(position.width - GUI.skin.verticalScrollbar.fixedWidth -
457-
(GUI.skin.box.padding.horizontal + GUI.skin.box.margin.horizontal)),
458-
GUILayout.ExpandHeight(false));
459-
EditorGUILayout.LabelField(sampleGroup.Name, m_boldStyle);
460-
EditorGUILayout.LabelField("Sample Unit: " + sampleGroup.Unit.ToString());
461-
if (samplesToDraw.Count > m_chartLimit)
462-
{
463-
string message = string.Format("Sample Group has more than {0} Samples. The first {0} Samples will be displayed. However, calculations are done according to the all samples received from the test run.", m_chartLimit);
464-
EditorGUILayout.HelpBox(message, MessageType.Warning, true);
465-
samplesToDraw = samplesToDraw.Take(m_chartLimit).ToList();
466-
}
467-
EditorGUILayout.BeginHorizontal(GUILayout.Height(100), GUILayout.ExpandHeight(false));
468-
469-
EditorGUILayout.BeginVertical(GUILayout.Width(100), GUILayout.ExpandHeight(true));
470-
Draw2Column("Max", max);
471-
GUILayout.FlexibleSpace();
472-
Color oldColor = GUI.contentColor;
473-
if (median < 0.01f)
474-
GUI.contentColor = m_colorWarningText;
475-
else
476-
GUI.contentColor = m_colorMedianText;
477-
Draw2Column("Median", median);
478-
GUI.contentColor = oldColor;
479-
480-
//Draw2Column("SD", (float)sampleGroup.StandardDeviation);
481-
//Draw2Column("P", (float)sampleGroup.PercentileValue);
482-
GUILayout.FlexibleSpace();
483-
Draw2Column("Min", min);
484-
EditorGUILayout.EndVertical();
485-
DrawBarGraph(position.width - 200, 100, samplesToDraw, graphMin, max, median);
486-
DrawBoxAndWhiskerPlot(50, 100, min, lowerQuartile, median, upperQuartile, max, min, max,
487-
(float)sampleGroup.StandardDeviation, m_colorWhite, m_colorBoxAndWhiskerBackground);
488-
EditorGUILayout.EndHorizontal();
489-
490-
EditorGUILayout.EndVertical();
491-
}
483+
EditorGUILayout.BeginHorizontal(GUILayout.Height(100), GUILayout.ExpandHeight(false));
484+
485+
EditorGUILayout.BeginVertical(GUILayout.Width(100), GUILayout.ExpandHeight(true));
486+
Draw2Column("Max", max);
487+
GUILayout.FlexibleSpace();
488+
Color oldColor = GUI.contentColor;
489+
if (median < 0.01f)
490+
GUI.contentColor = m_colorWarningText;
491+
else
492+
GUI.contentColor = m_colorMedianText;
493+
Draw2Column("Median", median);
494+
GUI.contentColor = oldColor;
495+
496+
//Draw2Column("SD", (float)sampleGroup.StandardDeviation);
497+
//Draw2Column("P", (float)sampleGroup.PercentileValue);
498+
GUILayout.FlexibleSpace();
499+
Draw2Column("Min", min);
500+
EditorGUILayout.EndVertical();
501+
DrawBarGraph(position.width - 200, 100, samplesToDraw, graphMin, max, median);
502+
DrawBoxAndWhiskerPlot(50, 100, min, lowerQuartile, median, upperQuartile, max, min, max,
503+
(float)sampleGroup.StandardDeviation, m_colorWhite, m_colorBoxAndWhiskerBackground);
504+
EditorGUILayout.EndHorizontal();
505+
506+
EditorGUILayout.EndVertical();
492507
}
493-
494-
EditorGUILayout.EndScrollView();
495-
EditorGUILayout.EndVertical();
496508
}
509+
510+
EditorGUILayout.EndScrollView();
511+
EditorGUILayout.EndVertical();
497512
}
498513
}
499514

@@ -593,12 +608,8 @@ public bool DrawStart(Rect r)
593608
if (Event.current.type != EventType.Repaint)
594609
return false;
595610

596-
if (!CheckAndSetupMaterial())
597-
return false;
598-
599611
GL.PushMatrix();
600-
CheckAndSetupMaterial();
601-
m_material.SetPass(0);
612+
SetupMaterial();
602613

603614
Matrix4x4 matrix = new Matrix4x4();
604615
matrix.SetTRS(new Vector3(r.x, r.y, 0), Quaternion.identity, Vector3.one);

Runtime/AssemblyInfo.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
using System.Runtime.CompilerServices;
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
[assembly: AssemblyTitle("Unity.PerformanceTesting")]
25

36
[assembly: InternalsVisibleTo("Unity.PerformanceTesting.Editor")]
47
[assembly: InternalsVisibleTo("Unity.PerformanceTesting.Tests.Runtime")]
8+
9+
[assembly: AssemblyVersion("3.0.0")]

Runtime/Attributes/VersionAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class VersionAttribute : NUnitAttribute, IApplyToTest
1414
/// <summary>
1515
/// Test version.
1616
/// </summary>
17-
public string Version;
17+
public string Version { get; }
1818

1919
/// <summary>
2020
/// Adds attribute to specify test version.

0 commit comments

Comments
 (0)