Skip to content

Commit 00d3f77

Browse files
committed
Add reload test result feature
1 parent 1d0046e commit 00d3f77

6 files changed

+31
-23
lines changed

Diff for: Editor/PerformanceTestingReportViewerWindow.cs

+6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ public void CreateGUI()
2727
var asset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(path);
2828
asset.CloneTree(rootVisualElement);
2929
viewer = rootVisualElement.Q<Editor.UI.PerformanceTestReportViewer>();
30+
viewer.RequestReload += () => InitViewer(viewer);
31+
InitViewer(viewer);
32+
}
3033

34+
private void InitViewer(Editor.UI.PerformanceTestReportViewer viewer)
35+
{
3136
if (File.Exists(EditorConfigPath))
3237
viewerOptions = ViewerOptions.DeserializeFromString(File.ReadAllText(EditorConfigPath));
3338
else
@@ -38,6 +43,7 @@ public void CreateGUI()
3843
ViewerModule.Instance.ViewerOptions = viewerOptions;
3944

4045
viewer.Init(viewerOptions);
46+
4147
}
4248

4349
private void Update()

Diff for: Editor/UI/ChartUtility.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,10 @@ public static void GenerateBars(int index, int totalCount, double min, double ma
155155
double gap = max - min;
156156
float yPosStart = ChartUtility.YPosByIndex(chartRect, index, totalCount, out float ySize);
157157
float ySpacing = 1;
158-
float eachYSize = (ySize - (values.Length + 1) * ySpacing) / values.Length;
158+
float yMargin = 6;
159+
float eachYSize = (ySize - (2 * yMargin) - (values.Length * ySpacing)) / values.Length;
159160
float realYSize = Math.Min(10, eachYSize);
160-
float yMargin = (ySize - realYSize * values.Length - ySpacing * (values.Length - 1)) / 2f;
161+
yMargin = (ySize - (realYSize + ySpacing) * values.Length) / 2f;
161162
for (int i = 0; i < values.Length; i++)
162163
{
163164
float yPos = yPosStart + yMargin + i * ySpacing + i * realYSize;

Diff for: Editor/UI/Layouts/BarsVisualizer.uxml

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
22
<ui:VisualElement name="VisualElement" style="flex-grow: 1; min-width: 500px; min-height: 400px; border-left-color: rgb(29, 29, 29); border-right-color: rgb(29, 29, 29); border-top-color: rgb(29, 29, 29); border-bottom-color: rgb(29, 29, 29); border-left-width: 3px; border-right-width: 3px; border-top-width: 3px; border-bottom-width: 3px; margin-left: 1px; margin-right: 1px; margin-top: 1px; margin-bottom: 1px;">
3-
<ui:Label tabindex="-1" display-tooltip-when-elided="true" name="headerArea" style="background-color: rgb(55, 55, 55);">
4-
<ui:Label tabindex="-1" text="Label" display-tooltip-when-elided="true" name="header" style="margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0; font-size: 16px; -unity-text-align: middle-center; -unity-font-style: bold;" />
5-
</ui:Label>
3+
<ui:Label tabindex="-1" text="Label" display-tooltip-when-elided="true" name="header" style="margin-left: 20px; margin-right: 20px; margin-top: 2px; margin-bottom: 2px; padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0; font-size: 16px; -unity-text-align: middle-center; -unity-font-style: bold; text-overflow: ellipsis; white-space: nowrap;" />
64
<ui:VisualElement name="chartArea" style="flex-grow: 1; flex-direction: row; padding-top: 20px; padding-left: 20px;">
7-
<ui:VisualElement name="renderArea" style="flex-grow: 1; border-left-color: rgba(0, 0, 0, 0.61); border-right-color: rgba(0, 0, 0, 0.61); border-top-color: rgba(0, 0, 0, 0.61); border-bottom-color: rgba(0, 0, 0, 0.61); border-left-width: 2px; border-right-width: 2px; border-top-width: 2px; border-bottom-width: 2px;" />
8-
<ui:VisualElement name="yAxis" style="flex-grow: 1; width: 80px; max-width: 50%; min-width: 50%;" />
5+
<ui:VisualElement name="renderArea" style="flex-grow: 1; border-left-color: rgba(0, 0, 0, 0.61); border-right-color: rgba(0, 0, 0, 0.61); border-top-color: rgba(0, 0, 0, 0.61); border-bottom-color: rgba(0, 0, 0, 0.61); border-left-width: 2px; border-right-width: 2px; border-top-width: 2px; border-bottom-width: 2px; min-width: 35%;" />
6+
<ui:VisualElement name="yAxis" style="flex-grow: 1; width: 80px; max-width: 50%; min-width: 10%;" />
97
</ui:VisualElement>
108
<ui:VisualElement name="descriptionArea" style="margin-left: 20px;">
119
<ui:VisualElement name="xAxis" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 5px; max-height: 25px; min-height: 25px; height: 25px;" />

Diff for: Editor/UI/PerformanceTestReportViewer.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ public class PerformanceTestReportViewer : VisualElement
1818

1919
private static readonly string layoutPath = $"{Constants.LayoutPath}/{nameof(PerformanceTestReportViewer)}.uxml";
2020

21+
public event Action RequestReload;
2122
public event Action RequestRefresh;
22-
23+
24+
private Button reloadButton;
2325
private ScrollView sampleTypesScrollView;
2426
private ScrollView contextsScrollView;
2527
private TestResultListView testResultListView;
@@ -37,6 +39,7 @@ public PerformanceTestReportViewer()
3739
{
3840
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(layoutPath).CloneTree(this);
3941

42+
reloadButton = this.Q<Button>(nameof(reloadButton));
4043
sampleTypesScrollView = this.Q<ScrollView>(nameof(sampleTypesScrollView));
4144
contextsScrollView = this.Q<ScrollView>(nameof(contextsScrollView));
4245
testResultListView = this.Q<TestResultListView>(nameof(testResultListView));
@@ -46,6 +49,8 @@ public PerformanceTestReportViewer()
4649
viewerTypeDropdown = this.Q<DropdownField>(nameof(viewerTypeDropdown));
4750
tagsScrollView = this.Q<ScrollView>(nameof(tagsScrollView));
4851

52+
testResultListView.OnTreeViewItemSelected += OnTreeViewItemSelected;
53+
reloadButton.clicked += () => RequestReload?.Invoke();
4954
RequestRefresh += Refresh;
5055
}
5156

@@ -58,8 +63,6 @@ public void Init(ViewerOptions viewerOptions)
5863
viewerOptions.IsSampleTargetOn, viewerOptions.SetIsSampleTargetOn,
5964
() => RequestRefresh?.Invoke());
6065
testResultListView.Init(viewerOptions);
61-
62-
testResultListView.OnTreeViewItemSelected += OnTreeViewItemSelected;
6366
}
6467

6568
private void Refresh()

Diff for: Editor/UI/TestResultListView.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,7 @@ public TestResultListView()
6565
{
6666
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(layoutPath).CloneTree(this);
6767
resultsTreeView = this.Q<TreeView>(nameof(resultsTreeView));
68-
}
69-
70-
public void Init(ViewerOptions viewerOptions)
71-
{
72-
this.viewerOptions = viewerOptions;
7368

74-
resultsTreeView.Clear();
75-
76-
if (ViewerModule.Instance.PerformanceTestResults == null)
77-
return;
78-
79-
resultsTreeView.SetRootItems(BuildTreeDataList());
8069
resultsTreeView.makeItem = MakeItem;
8170
resultsTreeView.bindItem = BindItem;
8271

@@ -88,6 +77,17 @@ public void Init(ViewerOptions viewerOptions)
8877
var item = selectedList.Single() as ITreeViewItem;
8978
OnTreeViewItemSelected?.Invoke(item);
9079
};
80+
}
81+
82+
public void Init(ViewerOptions viewerOptions)
83+
{
84+
this.viewerOptions = viewerOptions;
85+
resultsTreeView.Clear();
86+
87+
if (ViewerModule.Instance.PerformanceTestResults == null)
88+
return;
89+
90+
resultsTreeView.SetRootItems(BuildTreeDataList());
9191
resultsTreeView.ExpandRootItems();
9292
}
9393

Diff for: Editor/UI/Visualizers/BarsVisualizer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ private void OnMouseMove(MouseMoveEvent evt)
174174

175175
if (_groupNames != null)
176176
{
177-
int groupIndex = index % _groupNames.Length;
178-
int valueIndex = index / _groupNames.Length;
177+
int groupIndex = index / showingElements.Length;
178+
int valueIndex = index % showingElements.Length;
179179
valueTooltip.text = showingElements[valueIndex].Values[groupIndex]!.Value.ToString("F2");
180180
}
181181
else

0 commit comments

Comments
 (0)