LeviLamina
Loading...
Searching...
No Matches
ProfilerLite.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/file/OutputFileStream.h"
7#include "mc/deps/core/file/PathBuffer.h"
8#include "mc/deps/core/utility/pub_sub/Subscription.h"
9#include "mc/network/TrackerType.h"
10#include "mc/platform/brstd/function_ref.h"
11#include "mc/profile/ProfilerLiteTelemetry.h"
12
13// auto generated forward declare list
14// clang-format off
18namespace Bedrock { class ScopeExit; }
19namespace Core { class Path; }
20// clang-format on
21
22class ProfilerLite {
23public:
24 // ProfilerLite inner types declare
25 // clang-format off
26 struct RealtimeFrameData;
27 struct ScopedData;
28 // clang-format on
29
30 // ProfilerLite inner types define
31 enum class ScopeTag : int {
32 None = 0,
33 Root = 1,
34 PreFrame = 2,
35 BeginFrame = 3,
37 EndFrame = 5,
38 Present = 6,
39 Input = 7,
40 ClientSimTick = 8,
41 ClientRealTick = 9,
42 ServerInstance = 10,
43 ServerSimTick = 11,
44 ServerRealTick = 12,
45 Render = 13,
46 RenderLevel = 14,
47 TickAndRenderUI = 15,
48 UpdateFrame = 16,
49 UpdateGame = 17,
50 Last = 17,
51 SimTickFirst = 8,
52 SimTickLast = 12,
53 RenderTickFirst = 13,
54 RenderTickLast = 15,
55 };
56
58 public:
59 // member variables
60 // NOLINTBEGIN
61 ::ll::TypedStorage<4, 4, uint> mGameUpdates;
62 ::ll::TypedStorage<4, 4, uint> mFrames;
63 ::ll::TypedStorage<4, 4, float> mFPS;
64 ::ll::TypedStorage<4, 4, float> mGameUpdateFPS;
65 ::ll::TypedStorage<4, 4, float> mFrameTime;
66 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mLastFrame;
67 ::ll::TypedStorage<1, 1, bool> mFirstFrame;
68 // NOLINTEND
69 };
70
71 struct ScopedData {
72 public:
73 // member variables
74 // NOLINTBEGIN
75 ::ll::TypedStorage<8, 8, char const*> mName;
76 ::ll::TypedStorage<4, 4, ::ProfilerLite::ScopeTag> mScope;
77 ::ll::TypedStorage<4, 4, ::ProfilerLite::ScopeTag> mBaseScope;
78 ::ll::TypedStorage<8, 8, ::ProfilerLite::ScopedData*> mParent;
79 ::ll::TypedStorage<4, 4, int> mTabCount;
80 ::ll::TypedStorage<8, 24, ::std::vector<::ProfilerLite::ScopedData*>> mChildren;
81 ::ll::TypedStorage<4, 4, int> mHitCount;
82 ::ll::TypedStorage<8, 8, double> mTotalTime;
83 ::ll::TypedStorage<8, 8, double> mTotalInclusiveTime;
84 ::ll::TypedStorage<8, 8, double> mMaxTimePerLoop;
85 ::ll::TypedStorage<8, 8, double> mFrameAccumulatedTime;
86 // NOLINTEND
87
88 public:
89 // member functions
90 // NOLINTBEGIN
91#ifdef LL_PLAT_C
92 MCNAPI void resetRecursive();
93#endif
94
95 MCNAPI ~ScopedData();
96 // NOLINTEND
97
98 public:
99 // destructor thunk
100 // NOLINTBEGIN
101 MCNAPI void $dtor();
102 // NOLINTEND
103 };
104
105 using EventSource = ::brstd::function_ref<
106 void(::brstd::function_ref<void(::std::string const&, double), void(::std::string const&, double)>)>;
107
108 using EventVisitor = ::brstd::function_ref<void(::std::string const&, double)>;
109
110public:
111 // member variables
112 // NOLINTBEGIN
113 ::ll::TypedStorage<8, 144, ::std::array<::ProfilerLite::ScopedData*, 18>> mCustomScopeDatas;
114 ::ll::TypedStorage<8, 96, ::ProfilerLite::ScopedData> mUninitializedScopedData;
115 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mLogFileName;
116 ::ll::TypedStorage<8, 296, ::Core::OutputFileStream> mLogFile;
117 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mScreenLoadLogFileName;
118 ::ll::TypedStorage<8, 296, ::Core::OutputFileStream> mScreenLoadLogFile;
119 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mEventLogFileName;
120 ::ll::TypedStorage<8, 296, ::Core::OutputFileStream> mEventLogFile;
121 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mSecondaryLogFileName;
122 ::ll::TypedStorage<8, 296, ::Core::OutputFileStream> mSecondaryLogFile;
123 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mSecondaryScreenLoadLogFileName;
124 ::ll::TypedStorage<8, 296, ::Core::OutputFileStream> mSecondaryScreenLoadLogFile;
125 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mSecondaryEventLogFileName;
126 ::ll::TypedStorage<8, 296, ::Core::OutputFileStream> mSecondaryEventLogFile;
127#ifdef LL_PLAT_C
128 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mMemTrackerConfigurationToggleSubscription;
129#endif
130 ::ll::TypedStorage<4, 4, float> mSecondsPerUpdate;
131 ::ll::TypedStorage<8, 8, double> mTime;
132 ::ll::TypedStorage<8, 8, double> mStartTime;
133 ::ll::TypedStorage<8, 8, double> mNextUpdateTime;
134 ::ll::TypedStorage<8, 8, double> mLastUpdateTime;
135 ::ll::TypedStorage<8, 8, double> mBenchmarkModeTime;
136 ::ll::TypedStorage<4, 4, int> mTicksToNextMemoryUpdate;
137 ::ll::TypedStorage<1, 1, bool> mBenchmarkModeDone;
138 ::ll::TypedStorage<1, 1, bool> mBenchmarkModeIsSetup;
139 ::ll::TypedStorage<1, 1, bool> mDefaultEnabled;
140 ::ll::TypedStorage<1, 1, bool> mForceEnabled;
141 ::ll::TypedStorage<1, 1, bool> mShouldCheckTreatments;
142 ::ll::TypedStorage<1, 1, bool> mCanLogToSecondaryFile;
143 ::ll::TypedStorage<8, 8, ::_ProfilerLiteTimer*> mActiveScope;
144 ::ll::TypedStorage<8, 16, ::std::map<::std::thread::id, ::_ProfilerLiteTimer*>> mThreadedActiveScopes;
145 ::ll::TypedStorage<8, 32, ::std::string> mCurrentGamestate;
146 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mDebugServerTickTime;
147 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mDebugServerNetworkTime;
148 ::ll::TypedStorage<4, 4, float> mDebugRemoteServerTickTime;
149 ::ll::TypedStorage<8, 72, ::ProfilerLiteTelemetry> mTelemetry;
150 ::ll::TypedStorage<8, 32, ::std::string> mCachedProfileString;
151 ::ll::TypedStorage<4, 16, ::std::array<uint, 4>> mLastNetworkStatSampleNum;
152 ::ll::TypedStorage<8, 8, uint64> mPrevTotalBytesWritten;
153 ::ll::TypedStorage<8, 8, uint64> mPrevTotalBytesRead;
154 ::ll::TypedStorage<8, 40, ::ProfilerLite::RealtimeFrameData> mFrameData;
155 // NOLINTEND
156
157public:
158 // member functions
159 // NOLINTBEGIN
160 MCAPI ProfilerLite();
161
162#ifdef LL_PLAT_C
163 MCAPI void _calculateRealtimeFrameData();
164
165 MCAPI void _getProfileStringRecursive(
167 uint64& writeCount,
168 uint64& remainingLength,
169 char*& stringBuilderTemp
170 );
171
172 MCFOLD void _shutdown();
173
174 MCAPI void applyProfilerOptions(bool isClientDiagnosticsEnabled);
175
176 MCAPI ::Bedrock::ScopeExit init(::Core::Path const& logFilePath);
177
178 MCAPI void logScreenCreationEvent(::std::string const& screenName, double creationTime, uchar clientID);
179
180 MCAPI void reset();
181
182 MCAPI bool tick(
183 bool isVSynced,
184 bool frameDiscarded,
185 bool outputProfilerInfo,
186 int benchmarkModeStartTime,
187 ::ProfilerResourceUsage const& resources,
188 bool logPackets
189 );
190#endif
191
192 MCAPI ~ProfilerLite();
193 // NOLINTEND
194
195public:
196 // static functions
197 // NOLINTBEGIN
198#ifdef LL_PLAT_C
199 MCAPI static void
200 _writeHeadersIfEmpty(::std::string const& header, ::Core::Path logFileName, ::Core::OutputFileStream& file);
201
202 MCAPI static void getNetworkStats(::NetworkStatMetrics& stats, uint& lastSampleNum, ::TrackerType type);
203#endif
204 // NOLINTEND
205
206public:
207 // static variables
208 // NOLINTBEGIN
209 MCAPI static ::ProfilerLite& gProfilerLiteInstance();
210
211 MCAPI static ::std::thread::id& sEmptyThreadID();
212 // NOLINTEND
213
214public:
215 // constructor thunks
216 // NOLINTBEGIN
217 MCAPI void* $ctor();
218 // NOLINTEND
219
220public:
221 // destructor thunk
222 // NOLINTBEGIN
223 MCAPI void $dtor();
224 // NOLINTEND
225};
Definition ScopeExit.h:7
Definition ClientInstance.h:5
Definition OutputFileStream.h:10
Definition Path.h:17
Definition ServerInstance.h:57
Definition _ProfilerLiteTimer.h:8
Definition function_ref.h:60
Definition NetworkStatMetrics.h:5
Definition ProfilerLite.h:57
Definition ProfilerLite.h:71
Definition ProfilerResourceUsage.h:5