Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions com.unity.multiplayer.mlapi/Editor/MLAPIProfilerModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ private class MLAPIModules

private static List<MLAPIProfilerCounter> CreateRPCCounters() => new List<MLAPIProfilerCounter>()
{
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NumberOfRPCsSent, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NumberOfRPCsReceived, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NumberOfRPCBatchesSent, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NumberOfRPCBatchesReceived, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NumberOfRPCQueueProcessed, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NumberOfRPCsInQueueSize, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NumberOfRPCsOutQueueSize, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcSent, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcReceived, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcBatchesSent, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcBatchesReceived, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcQueueProcessed, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcInQueueSize, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcOutQueueSize, m_Category = ProfilerCategory.Network.Name },
};

private static List<MLAPIProfilerCounter> CreateOperationsCounters() => new List<MLAPIProfilerCounter>()
Expand All @@ -64,11 +64,11 @@ private class MLAPIModules

private static List<MLAPIProfilerCounter> CreateMessagesCounters() => new List<MLAPIProfilerCounter>()
{
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NumberOfNamedMessages, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NumberOfUnnamedMessages, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NumberBytesSent, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NumberBytesReceived, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NumberNetworkVarsReceived, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NamedMessageReceived, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.UnnamedMessageReceived, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.ByteSent, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.ByteReceived, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.NetworkVarReceived, m_Category = ProfilerCategory.Network.Name },
};

private delegate List<MLAPIProfilerCounter> CounterListFactoryDelegate();
Expand Down
4 changes: 2 additions & 2 deletions com.unity.multiplayer.mlapi/Runtime/Core/NetworkBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ internal static void HandleNetworkVariableDeltas(List<INetworkVariable> networkV
long readStartPos = stream.Position;

networkVariableList[i].ReadDelta(stream, IsServer, localTick, remoteTick);
PerformanceDataManager.Increment(ProfilerConstants.NumberNetworkVarsReceived);
PerformanceDataManager.Increment(ProfilerConstants.NetworkVarReceived);

ProfilerStatManager.NetworkVarsRcvd.Record();

Expand Down Expand Up @@ -810,7 +810,7 @@ internal static void HandleNetworkVariableUpdate(List<INetworkVariable> networkV
long readStartPos = stream.Position;

networkVariableList[i].ReadField(stream, NetworkTickSystem.NoTick, NetworkTickSystem.NoTick);
PerformanceDataManager.Increment(ProfilerConstants.NumberNetworkVarsReceived);
PerformanceDataManager.Increment(ProfilerConstants.NetworkVarReceived);

ProfilerStatManager.NetworkVarsRcvd.Record();

Expand Down
6 changes: 3 additions & 3 deletions com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ internal IEnumerator TimeOutSwitchSceneProgress(SceneSwitchProgress switchSceneP

private void HandleRawTransportPoll(NetworkEvent networkEvent, ulong clientId, NetworkChannel networkChannel, ArraySegment<byte> payload, float receiveTime)
{
PerformanceDataManager.Increment(ProfilerConstants.NumberBytesReceived, payload.Count);
PerformanceDataManager.Increment(ProfilerConstants.ByteReceived, payload.Count);
ProfilerStatManager.BytesRcvd.Record(payload.Count);

switch (networkEvent)
Expand Down Expand Up @@ -1043,7 +1043,7 @@ internal void HandleIncomingData(ulong clientId, NetworkChannel networkChannel,
{
m_RpcBatcher.ReceiveItems(messageStream, ReceiveCallback, RpcQueueContainer.QueueItemType.ServerRpc, clientId, receiveTime);
ProfilerStatManager.RpcBatchesRcvd.Record();
PerformanceDataManager.Increment(ProfilerConstants.NumberOfRPCBatchesReceived);
PerformanceDataManager.Increment(ProfilerConstants.RpcBatchesReceived);
}
else
{
Expand All @@ -1061,7 +1061,7 @@ internal void HandleIncomingData(ulong clientId, NetworkChannel networkChannel,
{
m_RpcBatcher.ReceiveItems(messageStream, ReceiveCallback, RpcQueueContainer.QueueItemType.ClientRpc, clientId, receiveTime);
ProfilerStatManager.RpcBatchesRcvd.Record();
PerformanceDataManager.Increment(ProfilerConstants.NumberOfRPCBatchesReceived);
PerformanceDataManager.Increment(ProfilerConstants.RpcBatchesReceived);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ internal static void RpcReceiveQueueItem(ulong clientId, Stream stream, float re
}

ProfilerStatManager.RpcsRcvd.Record();
PerformanceDataManager.Increment(ProfilerConstants.NumberOfRPCsReceived);
PerformanceDataManager.Increment(ProfilerConstants.RpcReceived);

#if DEVELOPMENT_BUILD || UNITY_EDITOR
switch (queueItemType)
Expand Down Expand Up @@ -582,7 +582,7 @@ internal static void RpcReceiveQueueItem(ulong clientId, Stream stream, float re

internal static void HandleUnnamedMessage(ulong clientId, Stream stream)
{
PerformanceDataManager.Increment(ProfilerConstants.NumberOfUnnamedMessages);
PerformanceDataManager.Increment(ProfilerConstants.UnnamedMessageReceived);
ProfilerStatManager.UnnamedMessage.Record();
#if DEVELOPMENT_BUILD || UNITY_EDITOR
s_HandleUnnamedMessage.Begin();
Expand All @@ -595,7 +595,7 @@ internal static void HandleUnnamedMessage(ulong clientId, Stream stream)

internal static void HandleNamedMessage(ulong clientId, Stream stream)
{
PerformanceDataManager.Increment(ProfilerConstants.NumberOfNamedMessages);
PerformanceDataManager.Increment(ProfilerConstants.NamedMessageReceived);
ProfilerStatManager.NamedMessage.Record();
#if DEVELOPMENT_BUILD || UNITY_EDITOR
s_HandleNamedMessage.Begin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal static void Send(ulong clientId, byte messageType, NetworkChannel netwo

NetworkManager.Singleton.NetworkConfig.NetworkTransport.Send(clientId, new ArraySegment<byte>(buffer.GetBuffer(), 0, (int)buffer.Length), networkChannel);
ProfilerStatManager.BytesSent.Record((int)buffer.Length);
PerformanceDataManager.Increment(ProfilerConstants.NumberBytesSent, (int)buffer.Length);
PerformanceDataManager.Increment(ProfilerConstants.ByteSent, (int)buffer.Length);

#if !UNITY_2020_2_OR_NEWER
NetworkProfiler.EndEvent();
Expand All @@ -46,7 +46,7 @@ internal static void Send(byte messageType, NetworkChannel networkChannel, Netwo

NetworkManager.Singleton.NetworkConfig.NetworkTransport.Send(NetworkManager.Singleton.ConnectedClientsList[i].ClientId, new ArraySegment<byte>(buffer.GetBuffer(), 0, (int)buffer.Length), networkChannel);
ProfilerStatManager.BytesSent.Record((int)buffer.Length);
PerformanceDataManager.Increment(ProfilerConstants.NumberBytesSent, (int)buffer.Length);
PerformanceDataManager.Increment(ProfilerConstants.ByteSent, (int)buffer.Length);
}

#if !UNITY_2020_2_OR_NEWER
Expand Down Expand Up @@ -77,7 +77,7 @@ internal static void Send(byte messageType, NetworkChannel networkChannel, List<

NetworkManager.Singleton.NetworkConfig.NetworkTransport.Send(clientIds[i], new ArraySegment<byte>(buffer.GetBuffer(), 0, (int)buffer.Length), networkChannel);
ProfilerStatManager.BytesSent.Record((int)buffer.Length);
PerformanceDataManager.Increment(ProfilerConstants.NumberBytesSent, (int)buffer.Length);
PerformanceDataManager.Increment(ProfilerConstants.ByteSent, (int)buffer.Length);
}

#if !UNITY_2020_2_OR_NEWER
Expand Down Expand Up @@ -106,7 +106,7 @@ internal static void Send(byte messageType, NetworkChannel networkChannel, ulong

NetworkManager.Singleton.NetworkConfig.NetworkTransport.Send(NetworkManager.Singleton.ConnectedClientsList[i].ClientId, new ArraySegment<byte>(buffer.GetBuffer(), 0, (int)buffer.Length), networkChannel);
ProfilerStatManager.BytesSent.Record((int)buffer.Length);
PerformanceDataManager.Increment(ProfilerConstants.NumberBytesSent, (int)buffer.Length);
PerformanceDataManager.Increment(ProfilerConstants.ByteSent, (int)buffer.Length);
}

#if !UNITY_2020_2_OR_NEWER
Expand Down
6 changes: 3 additions & 3 deletions com.unity.multiplayer.mlapi/Runtime/Messaging/RpcBatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public void QueueItem(in RpcFrameQueueItem queueItem)

ProfilerStatManager.BytesSent.Record(queueItem.MessageData.Count);
ProfilerStatManager.RpcsSent.Record();
PerformanceDataManager.Increment(ProfilerConstants.NumberBytesSent, queueItem.MessageData.Count);
PerformanceDataManager.Increment(ProfilerConstants.NumberOfRPCsSent);
PerformanceDataManager.Increment(ProfilerConstants.ByteSent, queueItem.MessageData.Count);
PerformanceDataManager.Increment(ProfilerConstants.RpcSent);
}
}

Expand Down Expand Up @@ -178,7 +178,7 @@ public void SendItems(int thresholdBytes, SendCallbackType sendCallback)
entry.Value.Buffer.Position = 0;
entry.Value.IsEmpty = true;
ProfilerStatManager.RpcBatchesSent.Record();
PerformanceDataManager.Increment(ProfilerConstants.NumberOfRPCBatchesSent);
PerformanceDataManager.Increment(ProfilerConstants.RpcBatchesSent);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ public void AdvanceFrameHistory(RpcQueueHistoryFrame.QueueFrameType queueType)
if (queueType == RpcQueueHistoryFrame.QueueFrameType.Inbound)
{
ProfilerStatManager.RpcInQueueSize.Record((int)rpcQueueHistoryItem.TotalSize);
PerformanceDataManager.Increment(ProfilerConstants.NumberOfRPCsInQueueSize, (int)rpcQueueHistoryItem.TotalSize);
PerformanceDataManager.Increment(ProfilerConstants.RpcInQueueSize, (int)rpcQueueHistoryItem.TotalSize);
}
else
{
ProfilerStatManager.RpcOutQueueSize.Record((int)rpcQueueHistoryItem.TotalSize);
PerformanceDataManager.Increment(ProfilerConstants.NumberOfRPCsOutQueueSize, (int)rpcQueueHistoryItem.TotalSize);
PerformanceDataManager.Increment(ProfilerConstants.RpcOutQueueSize, (int)rpcQueueHistoryItem.TotalSize);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void ProcessReceiveQueue(NetworkUpdateStage currentStage)

NetworkManager.InvokeRpc(currentQueueItem);
ProfilerStatManager.RpcsQueueProc.Record();
PerformanceDataManager.Increment(ProfilerConstants.NumberOfRPCQueueProcessed);
PerformanceDataManager.Increment(ProfilerConstants.RpcQueueProcessed);
currentQueueItem = currentFrame.GetNextQueueItem();
}

Expand Down Expand Up @@ -130,7 +130,7 @@ public void InternalMessagesSendAndFlush()
InternalMessageSender.Send(clientId, NetworkConstants.ADD_OBJECT, queueItem.NetworkChannel, PoolStream);
}

PerformanceDataManager.Increment(ProfilerConstants.NumberOfRPCsSent, queueItem.ClientNetworkIds.Length);
PerformanceDataManager.Increment(ProfilerConstants.RpcSent, queueItem.ClientNetworkIds.Length);
ProfilerStatManager.RpcsSent.Record(queueItem.ClientNetworkIds.Length);
break;
}
Expand All @@ -141,7 +141,7 @@ public void InternalMessagesSendAndFlush()
InternalMessageSender.Send(clientId, NetworkConstants.DESTROY_OBJECT, queueItem.NetworkChannel, PoolStream);
}

PerformanceDataManager.Increment(ProfilerConstants.NumberOfRPCsSent, queueItem.ClientNetworkIds.Length);
PerformanceDataManager.Increment(ProfilerConstants.RpcSent, queueItem.ClientNetworkIds.Length);
ProfilerStatManager.RpcsSent.Record(queueItem.ClientNetworkIds.Length);
break;
}
Expand Down Expand Up @@ -232,8 +232,8 @@ private void SendFrameQueueItem(RpcFrameQueueItem queueItem)

//For each packet sent, we want to record how much data we have sent

PerformanceDataManager.Increment(ProfilerConstants.NumberBytesSent, (int)queueItem.StreamSize);
PerformanceDataManager.Increment(ProfilerConstants.NumberOfRPCsSent);
PerformanceDataManager.Increment(ProfilerConstants.ByteSent, (int)queueItem.StreamSize);
PerformanceDataManager.Increment(ProfilerConstants.RpcSent);
ProfilerStatManager.BytesSent.Record((int)queueItem.StreamSize);
ProfilerStatManager.RpcsSent.Record();
break;
Expand All @@ -245,12 +245,12 @@ private void SendFrameQueueItem(RpcFrameQueueItem queueItem)
NetworkManager.Singleton.NetworkConfig.NetworkTransport.Send(clientid, queueItem.MessageData, queueItem.NetworkChannel);

//For each packet sent, we want to record how much data we have sent
PerformanceDataManager.Increment(ProfilerConstants.NumberBytesSent, (int)queueItem.StreamSize);
PerformanceDataManager.Increment(ProfilerConstants.ByteSent, (int)queueItem.StreamSize);
ProfilerStatManager.BytesSent.Record((int)queueItem.StreamSize);
}

//For each client we send to, we want to record how many RPCs we have sent
PerformanceDataManager.Increment(ProfilerConstants.NumberOfRPCsSent, queueItem.ClientNetworkIds.Length);
PerformanceDataManager.Increment(ProfilerConstants.RpcSent, queueItem.ClientNetworkIds.Length);
ProfilerStatManager.RpcsSent.Record(queueItem.ClientNetworkIds.Length);

break;
Expand Down
26 changes: 13 additions & 13 deletions com.unity.multiplayer.mlapi/Runtime/Profiling/ProfilerConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ public static class ProfilerConstants
public const string Connections = nameof(Connections);
public const string ReceiveTickRate = nameof(ReceiveTickRate);

public const string NumberOfNamedMessages = nameof(NumberOfNamedMessages);
public const string NumberOfUnnamedMessages = nameof(NumberOfUnnamedMessages);
public const string NumberBytesSent = nameof(NumberBytesSent);
public const string NumberBytesReceived = nameof(NumberBytesReceived);
public const string NumberNetworkVarsReceived = nameof(NumberNetworkVarsReceived);
public const string NumberOfRPCsSent = nameof(NumberOfRPCsSent);
public const string NumberOfRPCsReceived = nameof(NumberOfRPCsReceived);
public const string NumberOfRPCBatchesSent = nameof(NumberOfRPCBatchesSent);
public const string NumberOfRPCBatchesReceived = nameof(NumberOfRPCBatchesReceived);
public const string NumberOfRPCQueueProcessed = nameof(NumberOfRPCQueueProcessed);
public const string NumberOfRPCsInQueueSize = nameof(NumberOfRPCsInQueueSize);
public const string NumberOfRPCsOutQueueSize = nameof(NumberOfRPCsOutQueueSize);
public const string NamedMessageReceived = nameof(NamedMessageReceived);
public const string UnnamedMessageReceived = nameof(UnnamedMessageReceived);
public const string ByteSent = nameof(ByteSent);
public const string ByteReceived = nameof(ByteReceived);
public const string NetworkVarReceived = nameof(NetworkVarReceived);
public const string RpcSent = nameof(RpcSent);
public const string RpcReceived = nameof(RpcReceived);
public const string RpcBatchesSent = nameof(RpcBatchesSent);
public const string RpcBatchesReceived = nameof(RpcBatchesReceived);
public const string RpcQueueProcessed = nameof(RpcQueueProcessed);
public const string RpcInQueueSize = nameof(RpcInQueueSize);
public const string RpcOutQueueSize = nameof(RpcOutQueueSize);
}
}
}
Loading