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