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
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 // NOLINTEND
95 };
96
97 using EventSource = ::brstd::function_ref<
98 void(::brstd::function_ref<void(::std::string const&, double), void(::std::string const&, double)>)>;
99
100 using EventVisitor = ::brstd::function_ref<void(::std::string const&, double)>;
101
102public:
103 // member variables
104 // NOLINTBEGIN
105 ::ll::TypedStorage<8, 144, ::std::array<::ProfilerLite::ScopedData*, 18>> mCustomScopeDatas;
106 ::ll::TypedStorage<8, 96, ::ProfilerLite::ScopedData> mUninitializedScopedData;
107 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mLogFileName;
108 ::ll::TypedStorage<8, 296, ::Core::OutputFileStream> mLogFile;
109 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mScreenLoadLogFileName;
110 ::ll::TypedStorage<8, 296, ::Core::OutputFileStream> mScreenLoadLogFile;
111 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mEventLogFileName;
112 ::ll::TypedStorage<8, 296, ::Core::OutputFileStream> mEventLogFile;
113 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mSecondaryLogFileName;
114 ::ll::TypedStorage<8, 296, ::Core::OutputFileStream> mSecondaryLogFile;
115 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mSecondaryScreenLoadLogFileName;
116 ::ll::TypedStorage<8, 296, ::Core::OutputFileStream> mSecondaryScreenLoadLogFile;
117 ::ll::TypedStorage<8, 32, ::Core::PathBuffer<::std::string>> mSecondaryEventLogFileName;
118 ::ll::TypedStorage<8, 296, ::Core::OutputFileStream> mSecondaryEventLogFile;
119#ifdef LL_PLAT_C
120 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mMemTrackerConfigurationToggleSubscription;
121#endif
122 ::ll::TypedStorage<4, 4, float> mSecondsPerUpdate;
123 ::ll::TypedStorage<8, 8, double> mTime;
124 ::ll::TypedStorage<8, 8, double> mStartTime;
125 ::ll::TypedStorage<8, 8, double> mNextUpdateTime;
126 ::ll::TypedStorage<8, 8, double> mLastUpdateTime;
127 ::ll::TypedStorage<8, 8, double> mBenchmarkModeTime;
128 ::ll::TypedStorage<4, 4, int> mTicksToNextMemoryUpdate;
129 ::ll::TypedStorage<1, 1, bool> mBenchmarkModeDone;
130 ::ll::TypedStorage<1, 1, bool> mBenchmarkModeIsSetup;
131 ::ll::TypedStorage<1, 1, bool> mDefaultEnabled;
132 ::ll::TypedStorage<1, 1, bool> mForceEnabled;
133 ::ll::TypedStorage<1, 1, bool> mShouldCheckTreatments;
134 ::ll::TypedStorage<1, 1, bool> mCanLogToSecondaryFile;
135 ::ll::TypedStorage<8, 8, ::_ProfilerLiteTimer*> mActiveScope;
136 ::ll::TypedStorage<8, 16, ::std::map<::std::thread::id, ::_ProfilerLiteTimer*>> mThreadedActiveScopes;
137 ::ll::TypedStorage<8, 32, ::std::string> mCurrentGamestate;
138 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mDebugServerTickTime;
139 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mDebugServerNetworkTime;
140 ::ll::TypedStorage<4, 4, float> mDebugRemoteServerTickTime;
141 ::ll::TypedStorage<8, 72, ::ProfilerLiteTelemetry> mTelemetry;
142 ::ll::TypedStorage<8, 32, ::std::string> mCachedProfileString;
143 ::ll::TypedStorage<4, 16, ::std::array<uint, 4>> mLastNetworkStatSampleNum;
144 ::ll::TypedStorage<8, 8, uint64> mPrevTotalBytesWritten;
145 ::ll::TypedStorage<8, 8, uint64> mPrevTotalBytesRead;
146 ::ll::TypedStorage<8, 40, ::ProfilerLite::RealtimeFrameData> mFrameData;
147 // NOLINTEND
148
149public:
150 // member functions
151 // NOLINTBEGIN
152#ifdef LL_PLAT_C
153 MCAPI void _getProfileStringRecursive(
155 uint64& writeCount,
156 uint64& remainingLength,
157 char*& stringBuilderTemp
158 );
159
160 MCFOLD void _shutdown();
161
162 MCAPI void applyProfilerOptions(bool isClientDiagnosticsEnabled);
163#endif
164
165 MCAPI ::_ProfilerLiteTimer* getActiveScope(::std::thread::id threadId);
166
167#ifdef LL_PLAT_C
168 MCAPI ::Bedrock::ScopeExit init(::Core::Path const& logFilePath);
169
170 MCAPI void initWithFlightingAndOptions(bool isClientDiagnosticsEnabled);
171
172 MCAPI void logMultipleTimedEvents(
174 void(::brstd::function_ref<void(::std::string const&, double), void(::std::string const&, double)>)> events
175 );
176
177 MCAPI void logScreenCreationEvent(::std::string const& screenName, double creationTime, uchar clientID);
178
179 MCAPI void reset();
180#endif
181
182 MCAPI void setActiveScope(::std::thread::id threadId, ::_ProfilerLiteTimer* newScope);
183
184#ifdef LL_PLAT_C
185 MCAPI bool tick(
186 bool isVSynced,
187 bool frameDiscarded,
188 bool outputProfilerInfo,
189 int benchmarkModeStartTime,
190 ::ProfilerResourceUsage const& resources,
191 bool logPackets
192 );
193#endif
194 // NOLINTEND
195
196public:
197 // static functions
198 // NOLINTBEGIN
199#ifdef LL_PLAT_C
200 MCAPI static void
201 _writeHeadersIfEmpty(::std::string const& header, ::Core::Path logFileName, ::Core::OutputFileStream& file);
202
203 MCAPI static void getNetworkStats(::NetworkStatMetrics& stats, uint& lastSampleNum, ::TrackerType type);
204#endif
205 // NOLINTEND
206
207public:
208 // static variables
209 // NOLINTBEGIN
210 MCAPI static ::ProfilerLite& gProfilerLiteInstance();
211 // NOLINTEND
212};
Definition ScopeExit.h:7
Definition ClientInstance.h:5
Definition OutputFileStream.h:10
Definition Path.h:11
Definition ProfilerLite.h:22
Definition ServerInstance.h:76
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