-
Notifications
You must be signed in to change notification settings - Fork 461
Expand file tree
/
Copy pathProfilerCountersInfo.cs
More file actions
103 lines (84 loc) · 5.93 KB
/
ProfilerCountersInfo.cs
File metadata and controls
103 lines (84 loc) · 5.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using System;
#if UNITY_2020_2_OR_NEWER
using Unity.Profiling;
#endif
using UnityEngine;
namespace MLAPI.Profiling
{
public static class ProfilerCountersInfo
{
#if UNITY_2020_2_OR_NEWER && ENABLE_PROFILER
// Operations
public static ProfilerCounterValue<int> ConnectionsCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.NumberOfConnections,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
public static ProfilerCounterValue<int> TickRateCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.ReceiveTickRate,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
//Messages
public static ProfilerCounterValue<int> NamedMessagesCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.NumberOfNamedMessages,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
public static ProfilerCounterValue<int> UnnamedMessagesCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.NumberOfUnnamedMessages,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
public static ProfilerCounterValue<int> BytesSentCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.NumberBytesSent,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
public static ProfilerCounterValue<int> BytesReceivedCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.NumberBytesReceived,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
public static ProfilerCounterValue<int> NetworkVarsCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.NumberNetworkVarsReceived,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
//RPCs
public static ProfilerCounterValue<int> RPCsSentCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.NumberOfRPCsSent,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
public static ProfilerCounterValue<int> RPCsReceivedCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.NumberOfRPCsReceived,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
public static ProfilerCounterValue<int> RPCBatchesSentCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.NumberOfRPCBatchesSent,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
public static ProfilerCounterValue<int> RPCBatchesReceivedCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.NumberOfRPCBatchesReceived,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
public static ProfilerCounterValue<int> RPCQueueProcessedCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.NumberOfRPCQueueProcessed,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
public static ProfilerCounterValue<int> RPCsInQueueSizeCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.NumberOfRPCsInQueueSize,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
public static ProfilerCounterValue<int> RPCsOutQueueSizeCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.Network, ProfilerConstants.NumberOfRPCsOutQueueSize,
ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
[RuntimeInitializeOnLoadMethod]
static void RegisterMLAPIPerformanceEvent()
{
NetworkingManager.OnPerformanceDataEvent += OnPerformanceTickData;
}
static void OnPerformanceTickData(PerformanceTickData tickData)
{
//Operations
ConnectionsCounterValue.Value += tickData.GetData(ProfilerConstants.NumberOfConnections);
TickRateCounterValue.Value += tickData.GetData(ProfilerConstants.ReceiveTickRate);
//Messages
NamedMessagesCounterValue.Value += tickData.GetData(ProfilerConstants.NumberOfNamedMessages);
UnnamedMessagesCounterValue.Value += tickData.GetData(ProfilerConstants.NumberOfUnnamedMessages);
BytesSentCounterValue.Value += tickData.GetData(ProfilerConstants.NumberBytesSent);
BytesReceivedCounterValue.Value += tickData.GetData(ProfilerConstants.NumberBytesReceived);
NetworkVarsCounterValue.Value += tickData.GetData(ProfilerConstants.NumberNetworkVarsReceived);
//RPCs
RPCsSentCounterValue.Value += tickData.GetData(ProfilerConstants.NumberOfRPCsSent);
RPCsReceivedCounterValue.Value += tickData.GetData(ProfilerConstants.NumberOfRPCsReceived);
RPCBatchesSentCounterValue.Value += tickData.GetData(ProfilerConstants.NumberOfRPCBatchesSent);
RPCBatchesReceivedCounterValue.Value += tickData.GetData(ProfilerConstants.NumberOfRPCBatchesReceived);
RPCBatchesReceivedCounterValue.Value += tickData.GetData(ProfilerConstants.NumberOfRPCBatchesReceived);
RPCQueueProcessedCounterValue.Value += tickData.GetData(ProfilerConstants.NumberOfRPCQueueProcessed);
RPCsInQueueSizeCounterValue.Value += tickData.GetData(ProfilerConstants.NumberOfRPCsInQueueSize);
RPCsOutQueueSizeCounterValue.Value += tickData.GetData(ProfilerConstants.NumberOfRPCsOutQueueSize);
}
#endif
}
}