-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathStateChangeProfilerModule.cs
54 lines (45 loc) · 1.64 KB
/
StateChangeProfilerModule.cs
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
#if UNITY_EDITOR
using Unity.Entities;
using Unity.Profiling;
using Unity.Profiling.Editor;
namespace HelloCube.StateChange
{
[ProfilerModuleMetadata("StateChange")]
public class StateChangeProfilerModule : ProfilerModule
{
public struct FrameData : IComponentData
{
public long SpinPerf;
public long SetStatePerf;
}
static readonly string s_SpinPerfCounterLabel = "Spin System";
static readonly string s_SetStatePerfCounterLabel = "SetState System";
static readonly ProfilerCounterValue<long> s_SpinPerfCounterValue = new(
ProfilerCategory.Scripts,
s_SpinPerfCounterLabel,
ProfilerMarkerDataUnit.TimeNanoseconds,
ProfilerCounterOptions.FlushOnEndOfFrame);
static readonly ProfilerCounterValue<long> s_SetStatePerfCounterValue = new(
ProfilerCategory.Scripts,
s_SetStatePerfCounterLabel,
ProfilerMarkerDataUnit.TimeNanoseconds,
ProfilerCounterOptions.FlushOnEndOfFrame);
static readonly ProfilerCounterDescriptor[] k_ChartCounters =
{
new(s_SpinPerfCounterLabel, ProfilerCategory.Scripts),
new(s_SetStatePerfCounterLabel, ProfilerCategory.Scripts),
};
internal static long SpinPerf
{
set => s_SpinPerfCounterValue.Value = value;
}
internal static long UpdatePerf
{
set => s_SetStatePerfCounterValue.Value = value;
}
public StateChangeProfilerModule() : base(k_ChartCounters, ProfilerModuleChartType.StackedTimeArea)
{
}
}
}
#endif