Skip to content

Commit 42d4434

Browse files
author
Unity Technologies
committed
com.unity.test-framework.performance@2.5.1-preview
## [2.5.1] - 2021-01-05 Fix serialization for Performance Test Report window ## [2.5.0] - 2020-12-29 Add domain reload support Switch from Newtonsoft.Json to Unity json module ## [2.4.1] - 2020-11-05 Metadata collection was made public
1 parent 37209a9 commit 42d4434

35 files changed

+380
-111
lines changed

CHANGELOG.md

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

3+
## [2.5.1] - 2021-01-05
4+
5+
Fix serialization for Performance Test Report window
6+
7+
8+
## [2.5.0] - 2020-12-29
9+
10+
Add domain reload support
11+
Switch from Newtonsoft.Json to Unity json module
12+
13+
314
## [2.4.1] - 2020-11-05
415

516
Metadata collection was made public

Documentation~/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The Performance Testing Extension is intended to be used with, and complement, t
1111

1212
To install the Performance Testing Extension package
1313
1. Open the `manifest.json` file for your Unity project (located in the YourProject/Packages directory) in a text editor
14-
2. Add `"com.unity.test-framework.performance": "2.4.0",` to the dependencies
14+
2. Add `"com.unity.test-framework.performance": "2.5.0",` to the dependencies
1515
3. Save the manifest.json file
1616
4. Verify the Performance Testing Extension is now installed opening the Unity Package Manager window
1717

Editor/PerformanceTestRunSaver.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.IO;
3-
using Newtonsoft.Json;
43
using UnityEditor;
54
using UnityEngine;
65
using UnityEditor.TestTools.TestRunner.Api;
@@ -22,7 +21,10 @@ static TestRunnerInitializer()
2221
[Serializable]
2322
public class PerformanceTestRunSaver : ScriptableObject, ICallbacks
2423
{
25-
void ICallbacks.RunStarted(ITestAdaptor testsToRun) { }
24+
void ICallbacks.RunStarted(ITestAdaptor testsToRun)
25+
{
26+
PerformanceTest.Active = null;
27+
}
2628

2729
void ICallbacks.RunFinished(ITestResultAdaptor result)
2830
{
@@ -37,7 +39,7 @@ void ICallbacks.RunFinished(ITestResultAdaptor result)
3739
var xmlParser = new TestResultXmlParser();
3840
var run = xmlParser.GetPerformanceTestRunFromXml(xmlPath);
3941
if (run == null) return;
40-
File.WriteAllText(jsonPath, JsonConvert.SerializeObject(run, Formatting.Indented));
42+
File.WriteAllText(jsonPath, JsonUtility.ToJson(run, true));
4143
}
4244
catch (Exception e)
4345
{
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
struct SampleGroupAdditionalData
1+
namespace Unity.PerformanceTesting.Editor
22
{
3-
public float min;
4-
public float lowerQuartile;
5-
public float median;
6-
public float upperQuartile;
7-
public float max;
8-
}
3+
struct SampleGroupAdditionalData
4+
{
5+
public float min;
6+
public float lowerQuartile;
7+
public float median;
8+
public float upperQuartile;
9+
public float max;
10+
}
11+
}
Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
using System;
22

3-
struct SamplePoint : IComparable<SamplePoint>
3+
namespace Unity.PerformanceTesting.Editor
44
{
5-
public double sample;
6-
public int index;
7-
8-
public SamplePoint(double _sample, int _index)
5+
struct SamplePoint : IComparable<SamplePoint>
96
{
10-
sample = _sample;
11-
index = _index;
12-
}
7+
public double sample;
8+
public int index;
139

14-
public int CompareTo(SamplePoint other)
15-
{
16-
return sample.CompareTo(other.sample);
10+
public SamplePoint(double _sample, int _index)
11+
{
12+
sample = _sample;
13+
index = _index;
14+
}
15+
16+
public int CompareTo(SamplePoint other)
17+
{
18+
return sample.CompareTo(other.sample);
19+
}
1720
}
1821
}

Editor/TestReportGraph/TestListTable.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using Unity.PerformanceTesting.Data;
54
using UnityEditor;
65
using UnityEditor.IMGUI.Controls;
76
using UnityEngine;
87
using UnityEngine.Assertions;
8+
using Unity.PerformanceTesting.Data;
99

10-
namespace Unity.PerformanceTesting
10+
namespace Unity.PerformanceTesting.Editor
1111
{
1212
class TestListTableItem : TreeViewItem
1313
{
1414
public int index;
15-
public TestResult test;
15+
public PerformanceTestResult performanceTest;
1616
public double deviation;
1717
public double standardDeviation;
1818
public double median;
1919
public double min;
2020
public double max;
2121

22-
public TestListTableItem(int id, int depth, string displayName, TestResult test)
22+
public TestListTableItem(int id, int depth, string displayName, PerformanceTestResult performanceTest)
2323
: base(id, depth,
2424
displayName)
2525
{
26-
this.test = test;
26+
this.performanceTest = performanceTest;
2727

2828
index = id;
2929
deviation = 0f;
30-
if (test != null)
30+
if (performanceTest != null)
3131
{
32-
foreach (var sample in test.SampleGroups)
32+
foreach (var sample in performanceTest.SampleGroups)
3333
{
3434
if (sample.Name == "Time")
3535
{
@@ -231,7 +231,7 @@ void SortByMultipleColumns()
231231
orderedQuery = orderedQuery.ThenBy(l => l.displayName, ascending);
232232
break;
233233
case SortOption.SampleCount:
234-
orderedQuery = orderedQuery.ThenBy(l => l.test.SampleGroups.Count, ascending);
234+
orderedQuery = orderedQuery.ThenBy(l => l.performanceTest.SampleGroups.Count, ascending);
235235
break;
236236
case SortOption.Deviation:
237237
orderedQuery = orderedQuery.ThenBy(l => l.deviation, ascending);
@@ -265,7 +265,7 @@ IOrderedEnumerable<TestListTableItem> InitialOrder(IEnumerable<TestListTableItem
265265
case SortOption.Name:
266266
return myTypes.Order(l => l.displayName, ascending);
267267
case SortOption.SampleCount:
268-
return myTypes.Order(l => l.test.SampleGroups.Count, ascending);
268+
return myTypes.Order(l => l.performanceTest.SampleGroups.Count, ascending);
269269
case SortOption.Deviation:
270270
return myTypes.Order(l => l.deviation, ascending);
271271
case SortOption.StandardDeviation:
@@ -309,7 +309,7 @@ void CellGUI(Rect cellRect, TestListTableItem item, MyColumns column, ref RowGUI
309309
EditorGUI.LabelField(cellRect, string.Format("{0}", item.displayName));
310310
break;
311311
case MyColumns.SampleCount:
312-
EditorGUI.LabelField(cellRect, string.Format("{0}", item.test.SampleGroups.Count));
312+
EditorGUI.LabelField(cellRect, string.Format("{0}", item.performanceTest.SampleGroups.Count));
313313
break;
314314
case MyColumns.Deviation:
315315
EditorGUI.LabelField(cellRect, string.Format("{0:f2}", item.deviation));

Editor/TestReportGraph/TestReportWindow.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
using UnityEditor.IMGUI.Controls;
77
using System.IO;
88
using System.Linq;
9-
using Newtonsoft.Json;
109
using Unity.PerformanceTesting.Data;
1110
using Unity.PerformanceTesting.Runtime;
1211

13-
namespace Unity.PerformanceTesting
12+
namespace Unity.PerformanceTesting.Editor
1413
{
1514
public class TestReportWindow : EditorWindow
1615
{
@@ -57,6 +56,8 @@ public class TestReportWindow : EditorWindow
5756
Vector2 m_sampleGroupScroll = new Vector2(0, 0);
5857
List<SampleGroupAdditionalData> m_sampleGroupAdditionalData = new List<SampleGroupAdditionalData>();
5958

59+
private const int m_chartLimit = 1000;
60+
6061
private void CreateTestListTable()
6162
{
6263
if (m_testListTreeViewState == null)
@@ -97,7 +98,7 @@ public void SelectTest(string name)
9798
}
9899
}
99100

100-
public void SelectTest(TestResult result)
101+
public void SelectTest(PerformanceTestResult result)
101102
{
102103
m_selectedTest = result.Name;
103104

@@ -173,7 +174,7 @@ private void LoadData()
173174
if (!File.Exists(filePath)) return;
174175

175176
string json = File.ReadAllText(filePath);
176-
m_resultsData = JsonConvert.DeserializeObject<Run>(json);
177+
m_resultsData = JsonUtility.FromJson<Run>(json);
177178
ResetFileCheck();
178179

179180
List<SamplePoint> samplePoints = new List<SamplePoint>();
@@ -304,7 +305,6 @@ private void Refresh()
304305
SelectTest(m_selectedTest);
305306
else
306307
SelectTest(0);
307-
308308
Repaint();
309309
}
310310

@@ -446,7 +446,7 @@ private void Draw()
446446
{
447447
var data = m_sampleGroupAdditionalData[dataIndex];
448448
dataIndex++;
449-
449+
var samplesToDraw = sampleGroup.Samples;
450450
float min = data.min;
451451
float lowerQuartile = data.lowerQuartile;
452452
float median = data.median;
@@ -461,7 +461,12 @@ private void Draw()
461461
GUILayout.ExpandHeight(false));
462462
EditorGUILayout.LabelField(sampleGroup.Name, m_boldStyle);
463463
EditorGUILayout.LabelField("Sample Unit: " + sampleGroup.Unit.ToString());
464-
464+
if (samplesToDraw.Count > m_chartLimit)
465+
{
466+
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);
467+
EditorGUILayout.HelpBox(message, MessageType.Warning, true);
468+
samplesToDraw = samplesToDraw.Take(m_chartLimit).ToList();
469+
}
465470
EditorGUILayout.BeginHorizontal(GUILayout.Height(100), GUILayout.ExpandHeight(false));
466471

467472
EditorGUILayout.BeginVertical(GUILayout.Width(100), GUILayout.ExpandHeight(true));
@@ -480,7 +485,7 @@ private void Draw()
480485
GUILayout.FlexibleSpace();
481486
Draw2Column("Min", min);
482487
EditorGUILayout.EndVertical();
483-
DrawBarGraph(position.width - 200, 100, sampleGroup.Samples, graphMin, max, median);
488+
DrawBarGraph(position.width - 200, 100, samplesToDraw, graphMin, max, median);
484489
DrawBoxAndWhiskerPlot(50, 100, min, lowerQuartile, median, upperQuartile, max, min, max,
485490
(float)sampleGroup.StandardDeviation, m_colorWhite, m_colorBoxAndWhiskerBackground);
486491
EditorGUILayout.EndHorizontal();

Editor/TestResultXmlParser.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Linq;
55
using System.Text.RegularExpressions;
66
using System.Xml.Linq;
7-
using Newtonsoft.Json;
87
using Unity.PerformanceTesting.Data;
98
using UnityEngine;
109

@@ -112,11 +111,11 @@ private Run DeserializeMetadata(IEnumerable<XElement> output)
112111
return null;
113112
}
114113

115-
private TestResult TryDeserializePerformanceTestResultJsonObject(string json)
114+
private PerformanceTestResult TryDeserializePerformanceTestResultJsonObject(string json)
116115
{
117116
try
118117
{
119-
return JsonConvert.DeserializeObject<TestResult>(json);
118+
return JsonUtility.FromJson<PerformanceTestResult>(json);
120119
}
121120
catch (Exception e)
122121
{
@@ -131,7 +130,7 @@ private Run TryDeserializePerformanceTestRunJsonObject(string json)
131130
{
132131
try
133132
{
134-
return JsonConvert.DeserializeObject<Run>(json);
133+
return JsonUtility.FromJson<Run>(json);
135134
}
136135
catch (Exception e)
137136
{

Editor/TestRunBuilder.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.IO;
44
using System.Linq;
55
using System.Text.RegularExpressions;
6-
using Newtonsoft.Json;
76
using Unity.PerformanceTesting.Data;
87
using Unity.PerformanceTesting.Editor;
98
using Unity.PerformanceTesting.Runtime;
@@ -155,7 +154,7 @@ private void CreatePerformanceTestRunJson(Run run)
155154

156155
private string CreatePerformancePlayerPreferences(Run run)
157156
{
158-
var json = JsonConvert.SerializeObject(run, Formatting.Indented);
157+
var json = JsonUtility.ToJson(run, true);
159158
PlayerPrefs.SetString(Utils.PlayerPrefKeyRunJSON, json);
160159
return json;
161160
}

Editor/Unity.PerformanceTesting.Editor.asmdef

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
"allowUnsafeCode": false,
1313
"overrideReferences": true,
1414
"precompiledReferences": [
15-
"nunit.framework.dll",
16-
"Newtonsoft.Json.dll"
15+
"nunit.framework.dll"
1716
],
1817
"autoReferenced": false,
1918
"defineConstraints": [],

0 commit comments

Comments
 (0)