-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jeickhoff
committed
Jul 31, 2023
1 parent
db241d0
commit aa32de7
Showing
14 changed files
with
171 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Assets/Scripts/Player/Multiplay/MultiplayStats/MultiplayStatistics.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Unity.Profiling; | ||
using Unity.Profiling.Editor; | ||
|
||
|
||
// Defines profiler counters for collection and display by profiler module | ||
namespace Opencraft.Player.Multiplay.MultiplayStats | ||
{ | ||
public class MultiplayStatistics | ||
{ | ||
public static readonly ProfilerCategory MultiplayCategory = ProfilerCategory.Scripts; | ||
|
||
public const string RoundTripTimeName = "Round Trip Time (ms)"; | ||
public static readonly ProfilerCounterValue<double> MultiplayRoundTripTime = | ||
new ProfilerCounterValue<double>(MultiplayCategory, RoundTripTimeName, ProfilerMarkerDataUnit.Count); | ||
|
||
public const string BitRateName = "BitRate"; | ||
public static readonly ProfilerCounterValue<double> MultiplayBitRate = | ||
new ProfilerCounterValue<double>(MultiplayCategory ,BitRateName , ProfilerMarkerDataUnit.Count); | ||
|
||
public const string FPSName = "FPS"; | ||
public static readonly ProfilerCounterValue<double> MultiplayFPS = | ||
new ProfilerCounterValue<double>(MultiplayCategory ,"FPS" , ProfilerMarkerDataUnit.Count); | ||
|
||
public const string PacketLossName = "PacketLoss"; | ||
public static readonly ProfilerCounterValue<double> MultiplayPacketLoss = | ||
new ProfilerCounterValue<double>(MultiplayCategory ,"PacketLoss" , ProfilerMarkerDataUnit.Percent); | ||
} | ||
|
||
[System.Serializable] | ||
[ProfilerModuleMetadata("Multiplay Statistics")] | ||
public class MultiplayProfilerModule : ProfilerModule | ||
{ | ||
static readonly ProfilerCounterDescriptor[] k_Counters = new ProfilerCounterDescriptor[] | ||
{ | ||
new ProfilerCounterDescriptor(MultiplayStatistics.RoundTripTimeName, MultiplayStatistics.MultiplayCategory), | ||
new ProfilerCounterDescriptor(MultiplayStatistics.BitRateName, MultiplayStatistics.MultiplayCategory), | ||
new ProfilerCounterDescriptor(MultiplayStatistics.FPSName, MultiplayStatistics.MultiplayCategory), | ||
new ProfilerCounterDescriptor(MultiplayStatistics.PacketLossName, MultiplayStatistics.MultiplayCategory), | ||
}; | ||
|
||
// Ensure that both ProfilerCategory.Scripts and ProfilerCategory.Memory categories are enabled when our module is active. | ||
static readonly string[] k_AutoEnabledCategoryNames = new string[] | ||
{ | ||
ProfilerCategory.Scripts.Name | ||
}; | ||
|
||
|
||
// Pass the auto-enabled category names to the base constructor. | ||
public MultiplayProfilerModule() : base(k_Counters, autoEnabledCategoryNames: k_AutoEnabledCategoryNames) { } | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Assets/Scripts/Player/Multiplay/MultiplayStats/MultiplayStatistics.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Unity.Profiling; | ||
using Unity.Profiling.Editor; | ||
|
||
namespace Opencraft.Statistics | ||
{ | ||
public class GameStatistics | ||
{ | ||
public static readonly ProfilerCategory GameStatisticsCategory = ProfilerCategory.Scripts; | ||
|
||
public const string NumTerrainAreasClientName = "Number of Terrain Areas (Client)"; | ||
public static readonly ProfilerCounterValue<int> NumTerrainAreasClient = | ||
new ProfilerCounterValue<int>(GameStatisticsCategory, NumTerrainAreasClientName, ProfilerMarkerDataUnit.Count); | ||
public const string NumTerrainAreasServerName = "Number of Terrain Areas (Server)"; | ||
public static readonly ProfilerCounterValue<int> NumTerrainAreasServer = | ||
new ProfilerCounterValue<int>(GameStatisticsCategory, NumTerrainAreasServerName, ProfilerMarkerDataUnit.Count); | ||
|
||
} | ||
|
||
[System.Serializable] | ||
[ProfilerModuleMetadata("Game Statistics")] | ||
public class GameProfilerModule : ProfilerModule | ||
{ | ||
static readonly ProfilerCounterDescriptor[] k_Counters = new ProfilerCounterDescriptor[] | ||
{ | ||
new ProfilerCounterDescriptor(GameStatistics.NumTerrainAreasClientName, GameStatistics.GameStatisticsCategory), | ||
new ProfilerCounterDescriptor(GameStatistics.NumTerrainAreasServerName, GameStatistics.GameStatisticsCategory) | ||
}; | ||
|
||
// Ensure that both ProfilerCategory.Scripts and ProfilerCategory.Memory categories are enabled when our module is active. | ||
static readonly string[] k_AutoEnabledCategoryNames = new string[] | ||
{ | ||
ProfilerCategory.Scripts.Name | ||
}; | ||
|
||
|
||
// Pass the auto-enabled category names to the base constructor. | ||
public GameProfilerModule() : base(k_Counters, autoEnabledCategoryNames: k_AutoEnabledCategoryNames) { } | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Opencraft.Terrain.Authoring; | ||
using Unity.Entities; | ||
|
||
namespace Opencraft.Statistics | ||
{ | ||
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)] | ||
public partial struct StatisticsSystemServer : ISystem | ||
{ | ||
private EntityQuery _terrainAreaQuery; | ||
|
||
public void OnCreate(ref SystemState state) | ||
{ | ||
_terrainAreaQuery = state.EntityManager.CreateEntityQuery(typeof(TerrainArea)); | ||
} | ||
|
||
public void OnUpdate(ref SystemState state) | ||
{ | ||
GameStatistics.NumTerrainAreasServer.Value = _terrainAreaQuery.CalculateEntityCount(); | ||
} | ||
} | ||
|
||
[WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation)] | ||
public partial struct StatisticsSystemClient : ISystem | ||
{ | ||
private EntityQuery _terrainAreaQuery; | ||
|
||
public void OnCreate(ref SystemState state) | ||
{ | ||
_terrainAreaQuery = state.EntityManager.CreateEntityQuery(typeof(TerrainArea)); | ||
} | ||
|
||
public void OnUpdate(ref SystemState state) | ||
{ | ||
GameStatistics.NumTerrainAreasClient.Value = _terrainAreaQuery.CalculateEntityCount(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.