NetworkStats.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #if BESTHTTP_PROFILE && UNITY_2021_2_OR_NEWER
  2. using Unity.Profiling;
  3. namespace Best.HTTP.Profiler.Network
  4. {
  5. public sealed class NetworkStats
  6. {
  7. public const string CategoryName = "Best - Network";
  8. public static readonly ProfilerCategory Category = new ProfilerCategory(CategoryName, ProfilerCategoryColor.Scripts);
  9. // Sent
  10. public const string BufferedToSendName = "Buffered to Send";
  11. public static readonly ProfilerCounterValue<long> BufferedToSend = new ProfilerCounterValue<long>(Category, BufferedToSendName, ProfilerMarkerDataUnit.Bytes, ProfilerCounterOptions.FlushOnEndOfFrame | ProfilerCounterOptions.ResetToZeroOnFlush);
  12. public const string SentSinceLastFrameName = "Sent (Since Last Frame)";
  13. public static readonly ProfilerCounterValue<long> SentSinceLastFrame = new ProfilerCounterValue<long>(Category, SentSinceLastFrameName, ProfilerMarkerDataUnit.Bytes, ProfilerCounterOptions.FlushOnEndOfFrame | ProfilerCounterOptions.ResetToZeroOnFlush);
  14. public const string SentTotalName = "Sent Total";
  15. public static readonly ProfilerCounterValue<long> SentTotal = new ProfilerCounterValue<long>(Category, SentTotalName, ProfilerMarkerDataUnit.Bytes, ProfilerCounterOptions.FlushOnEndOfFrame | ProfilerCounterOptions.ResetToZeroOnFlush);
  16. // Received
  17. public const string ReceivedSinceLastFrameName = "Received (Since Last Frame)";
  18. public static readonly ProfilerCounterValue<long> ReceivedSinceLastFrame = new ProfilerCounterValue<long>(Category, ReceivedSinceLastFrameName, ProfilerMarkerDataUnit.Bytes, ProfilerCounterOptions.FlushOnEndOfFrame | ProfilerCounterOptions.ResetToZeroOnFlush);
  19. public const string ReceivedAndUnprocessedName = "Received and Unprocessed";
  20. public static readonly ProfilerCounterValue<long> ReceivedAndUnprocessed = new ProfilerCounterValue<long>(Category, ReceivedAndUnprocessedName, ProfilerMarkerDataUnit.Bytes, ProfilerCounterOptions.FlushOnEndOfFrame | ProfilerCounterOptions.ResetToZeroOnFlush);
  21. public const string ReceivedTotalName = "Received Total";
  22. public static readonly ProfilerCounterValue<long> ReceivedTotal = new ProfilerCounterValue<long>(Category, ReceivedTotalName, ProfilerMarkerDataUnit.Bytes, ProfilerCounterOptions.FlushOnEndOfFrame | ProfilerCounterOptions.ResetToZeroOnFlush);
  23. // Connections
  24. public const string OpenConnectionsName = "Open Connections";
  25. public static readonly ProfilerCounterValue<int> OpenConnectionsCounter = new ProfilerCounterValue<int>(Category, OpenConnectionsName, ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
  26. public const string TotalConnectionsName = "Total Connections";
  27. public static readonly ProfilerCounterValue<int> TotalConnectionsCounter = new ProfilerCounterValue<int>(Category, TotalConnectionsName, ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
  28. // DNS
  29. public const string TotalDNSCacheHits = "DNS Cache Hits";
  30. public static readonly ProfilerCounterValue<int> TotalDNSCacheHitsCounter = new ProfilerCounterValue<int>(Category, TotalDNSCacheHits, ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
  31. public const string TotalDNSCacheMiss = "DNS Cache Miss";
  32. public static readonly ProfilerCounterValue<int> TotalDNSCacheMissCounter = new ProfilerCounterValue<int>(Category, TotalDNSCacheMiss, ProfilerMarkerDataUnit.Count, ProfilerCounterOptions.FlushOnEndOfFrame);
  33. }
  34. }
  35. #endif