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#endif
176
177 MCAPI void calculateAndSetServerNetworkTime(::std::chrono::steady_clock::time_point tp);
178
179 MCAPI void calculateAndSetServerTickTimes(::std::chrono::steady_clock::time_point tp);
180
181 MCAPI ::_ProfilerLiteTimer* getActiveScope(::std::thread::id threadId);
182
183 MCAPI ::std::chrono::nanoseconds getServerTickTime() const;
184
185#ifdef LL_PLAT_C
186 MCAPI ::Bedrock::ScopeExit init(::Core::Path const& logFilePath);
187
188 MCAPI void initWithFlightingAndOptions(bool isClientDiagnosticsEnabled);
189
190 MCAPI bool isBenchmarkModeDone();
191
192 MCAPI void logMultipleTimedEvents(
194 void(::brstd::function_ref<void(::std::string const&, double), void(::std::string const&, double)>)> events
195 );
196
197 MCAPI void logScreenCreationEvent(::std::string const& screenName, double creationTime, uchar clientID);
198
199 MCAPI void reset();
200#endif
201
202 MCAPI void setActiveScope(::std::thread::id threadId, ::_ProfilerLiteTimer* newScope);
203
204#ifdef LL_PLAT_C
205 MCAPI bool tick(
206 bool isVSynced,
207 bool frameDiscarded,
208 bool outputProfilerInfo,
209 int benchmarkModeStartTime,
210 ::ProfilerResourceUsage const& resources,
211 bool logPackets
212 );
213#endif
214
215 MCAPI ~ProfilerLite();
216 // NOLINTEND
217
218public:
219 // static functions
220 // NOLINTBEGIN
221#ifdef LL_PLAT_C
222 MCAPI static void _writeHeadersIfEmpty(::std::string const& logFileName, ::Core::Path, ::Core::OutputFileStream&);
223
224 MCAPI static void getNetworkStats(::NetworkStatMetrics& stats, uint& lastSampleNum, ::TrackerType type);
225#endif
226 // NOLINTEND
227
228public:
229 // static variables
230 // NOLINTBEGIN
231 MCAPI static ::ProfilerLite& gProfilerLiteInstance();
232
233 MCAPI static ::std::thread::id& sEmptyThreadID();
234 // NOLINTEND
235
236public:
237 // constructor thunks
238 // NOLINTBEGIN
239 MCAPI void* $ctor();
240 // NOLINTEND
241
242public:
243 // destructor thunk
244 // NOLINTBEGIN
245 MCAPI void $dtor();
246 // NOLINTEND
247};
Definition ScopeExit.h:7
Definition ClientInstance.h:5
Definition OutputFileStream.h:10
Definition Path.h:12
Definition ServerInstance.h:64
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