@@ -10,70 +10,84 @@ namespace UnityEngine.InputSystem.Editor
10
10
/// <summary>
11
11
/// A profiler module that integrates Input System with the Profiler editor window.
12
12
/// </summary>
13
- [ ProfilerModuleMetadata ( "Input System" ) ]
13
+ [ ProfilerModuleMetadata ( "Input System" ) ]
14
14
internal sealed class InputSystemProfilerModule : ProfilerModule
15
15
{
16
16
/// <summary>
17
17
/// A profiler module detail view that extends the Profiler window and shows details for the selected frame.
18
18
/// </summary>
19
19
private sealed class InputSystemDetailsViewController : ProfilerModuleViewController
20
- {
21
- public InputSystemDetailsViewController ( ProfilerWindow profilerWindow )
22
- : base ( profilerWindow )
23
- { }
20
+ {
21
+ public InputSystemDetailsViewController ( ProfilerWindow profilerWindow )
22
+ : base ( profilerWindow )
23
+ { }
24
24
25
+ private Label m_UpdateCountLabel ;
25
26
private Label m_EventCountLabel ;
26
27
private Label m_EventSizeLabel ;
27
28
private Label m_AverageLatencyLabel ;
28
29
private Label m_MaxLatencyLabel ;
29
30
private Label m_EventProcessingTimeLabel ;
31
+ private Label m_DeviceCountLabel ;
32
+ private Label m_ControlCountLabel ;
33
+ private Label m_StateBufferSizeLabel ;
30
34
31
35
private Label CreateLabel ( )
32
36
{
33
37
return new Label ( ) { style = { paddingTop = 8 , paddingLeft = 8 } } ;
34
38
}
35
-
39
+
36
40
protected override VisualElement CreateView ( )
37
41
{
38
42
var view = new VisualElement ( ) ;
39
43
44
+ m_UpdateCountLabel = CreateLabel ( ) ;
40
45
m_EventCountLabel = CreateLabel ( ) ;
41
46
m_EventSizeLabel = CreateLabel ( ) ;
42
47
m_AverageLatencyLabel = CreateLabel ( ) ;
43
48
m_MaxLatencyLabel = CreateLabel ( ) ;
44
49
m_EventProcessingTimeLabel = CreateLabel ( ) ;
45
-
50
+ m_DeviceCountLabel = CreateLabel ( ) ;
51
+ m_ControlCountLabel = CreateLabel ( ) ;
52
+ m_StateBufferSizeLabel = CreateLabel ( ) ;
53
+
54
+ view . Add ( m_UpdateCountLabel ) ;
46
55
view . Add ( m_EventCountLabel ) ;
47
56
view . Add ( m_EventSizeLabel ) ;
48
57
view . Add ( m_AverageLatencyLabel ) ;
49
58
view . Add ( m_MaxLatencyLabel ) ;
50
59
view . Add ( m_EventProcessingTimeLabel ) ;
60
+ view . Add ( m_DeviceCountLabel ) ;
61
+ view . Add ( m_ControlCountLabel ) ;
62
+ view . Add ( m_StateBufferSizeLabel ) ;
51
63
52
- // Populate the label with the current data for the selected frame.
64
+ // Populate the label with the current data for the selected frame.
53
65
ReloadData ( ) ;
54
66
55
67
// Be notified when the selected frame index in the Profiler Window changes, so we can update the label.
56
68
ProfilerWindow . SelectedFrameIndexChanged += OnSelectedFrameIndexChanged ;
57
69
58
70
return view ;
59
71
}
60
-
72
+
61
73
protected override void Dispose ( bool disposing )
62
74
{
63
75
if ( disposing )
64
76
{
65
77
// Unsubscribe from the Profiler window event that we previously subscribed to.
66
78
ProfilerWindow . SelectedFrameIndexChanged -= OnSelectedFrameIndexChanged ;
67
79
}
68
-
80
+
69
81
base . Dispose ( disposing ) ;
70
82
}
71
83
72
84
void ReloadData ( )
73
85
{
74
86
var selectedFrameIndex = System . Convert . ToInt32 ( ProfilerWindow . selectedFrameIndex ) ;
75
-
76
- var eventCount = ProfilerDriver . GetFormattedCounterValue ( selectedFrameIndex ,
87
+
88
+ var updateCount = ProfilerDriver . GetFormattedCounterValue ( selectedFrameIndex ,
89
+ InputStatistics . Category . Name , InputStatistics . UpdateCountName ) ;
90
+ var eventCount = ProfilerDriver . GetFormattedCounterValue ( selectedFrameIndex ,
77
91
InputStatistics . Category . Name , InputStatistics . EventCountName ) ;
78
92
var eventSizeBytes = ProfilerDriver . GetFormattedCounterValue ( selectedFrameIndex ,
79
93
InputStatistics . Category . Name , InputStatistics . EventSizeName ) ;
@@ -83,38 +97,52 @@ void ReloadData()
83
97
InputStatistics . Category . Name , InputStatistics . MaxLatencyName ) ;
84
98
var eventProcessingTime = ProfilerDriver . GetFormattedCounterValue ( selectedFrameIndex ,
85
99
InputStatistics . Category . Name , InputStatistics . EventProcessingTimeName ) ;
100
+ var stateBufferSizeBytes = ProfilerDriver . GetFormattedCounterValue ( selectedFrameIndex ,
101
+ InputStatistics . Category . Name , InputStatistics . StateBufferSizeBytesName ) ;
102
+ var deviceCount = ProfilerDriver . GetFormattedCounterValue ( selectedFrameIndex ,
103
+ InputStatistics . Category . Name , InputStatistics . DeviceCountName ) ;
104
+ var controlCount = ProfilerDriver . GetFormattedCounterValue ( selectedFrameIndex ,
105
+ InputStatistics . Category . Name , InputStatistics . ControlCountName ) ;
86
106
107
+ m_UpdateCountLabel . text = $ "{ InputStatistics . UpdateCountName } : { updateCount } ";
87
108
m_EventCountLabel . text = $ "{ InputStatistics . EventCountName } : { eventCount } ";
88
109
m_EventSizeLabel . text = $ "{ InputStatistics . EventSizeName } : { eventSizeBytes } ";
89
110
m_AverageLatencyLabel . text = $ "{ InputStatistics . AverageLatencyName } : { averageLatency } ";
90
111
m_MaxLatencyLabel . text = $ "{ InputStatistics . MaxLatencyName } : { maxLatency } ";
91
112
m_EventProcessingTimeLabel . text = $ "{ InputStatistics . EventProcessingTimeName } : { eventProcessingTime } ";
113
+ m_StateBufferSizeLabel . text = $ "{ InputStatistics . StateBufferSizeBytesName } : { stateBufferSizeBytes } ";
114
+ m_DeviceCountLabel . text = $ "{ InputStatistics . DeviceCountName } : { deviceCount } ";
115
+ m_ControlCountLabel . text = $ "{ InputStatistics . ControlCountName } : { controlCount } ";
92
116
}
93
-
117
+
94
118
void OnSelectedFrameIndexChanged ( long selectedFrameIndex )
95
119
{
96
120
ReloadData ( ) ;
97
121
}
98
122
}
99
-
123
+
100
124
private static readonly ProfilerCounterDescriptor [ ] Counters = new ProfilerCounterDescriptor [ ]
101
125
{
102
- new ( InputStatistics . EventCountName , InputStatistics . Category ) ,
103
- new ( InputStatistics . EventSizeName , InputStatistics . Category ) ,
104
- new ( InputStatistics . AverageLatencyName , InputStatistics . Category ) ,
105
- new ( InputStatistics . MaxLatencyName , InputStatistics . Category ) ,
106
- new ( InputStatistics . EventProcessingTimeName , InputStatistics . Category ) ,
126
+ new ( InputStatistics . UpdateCountName , InputStatistics . Category ) ,
127
+ new ( InputStatistics . EventCountName , InputStatistics . Category ) ,
128
+ new ( InputStatistics . EventSizeName , InputStatistics . Category ) ,
129
+ new ( InputStatistics . StateBufferSizeBytesName , InputStatistics . Category ) ,
130
+ new ( InputStatistics . AverageLatencyName , InputStatistics . Category ) ,
131
+ new ( InputStatistics . MaxLatencyName , InputStatistics . Category ) ,
132
+ new ( InputStatistics . EventProcessingTimeName , InputStatistics . Category ) ,
133
+ new ( InputStatistics . DeviceCountName , InputStatistics . Category ) ,
134
+ new ( InputStatistics . ControlCountName , InputStatistics . Category ) ,
107
135
} ;
108
-
136
+
109
137
public InputSystemProfilerModule ( )
110
138
: base ( Counters )
111
- { }
112
-
139
+ { }
140
+
113
141
public override ProfilerModuleViewController CreateDetailsViewController ( )
114
142
{
115
143
return new InputSystemDetailsViewController ( ProfilerWindow ) ;
116
144
}
117
145
}
118
146
}
119
147
120
- #endif // UNITY_EDITOR
148
+ #endif // UNITY_EDITOR
0 commit comments