16#if defined(JPH_EXTERNAL_PROFILE)
24class alignas(16) ExternalProfileMeasurement :
public NonCopyable
28 ExternalProfileMeasurement(
const char *inName,
uint32 inColor = 0);
29 ~ExternalProfileMeasurement();
41JPH_SUPPRESS_WARNING_PUSH
45#define JPH_PROFILE_THREAD_START(name)
46#define JPH_PROFILE_THREAD_END()
47#define JPH_PROFILE_NEXTFRAME()
48#define JPH_PROFILE_DUMP(...)
51#define JPH_PROFILE_TAG2(line) profile##line
52#define JPH_PROFILE_TAG(line) JPH_PROFILE_TAG2(line)
63#define JPH_PROFILE(...) ExternalProfileMeasurement JPH_PROFILE_TAG(__LINE__)(__VA_ARGS__)
66#define JPH_PROFILE_FUNCTION() JPH_PROFILE(JPH_FUNCTION_NAME)
68JPH_SUPPRESS_WARNING_POP
70#elif defined(JPH_PROFILE_ENABLED)
91 void Dump(
const string_view &inTag = string_view());
116 Aggregator(
const char *inName) : mName(inName) { }
119 void AccumulateMeasurement(
uint64 inCyclesInCallWithChildren)
122 mTotalCyclesInCallWithChildren += inCyclesInCallWithChildren;
123 mMinCyclesInCallWithChildren = min(inCyclesInCallWithChildren, mMinCyclesInCallWithChildren);
124 mMaxCyclesInCallWithChildren = max(inCyclesInCallWithChildren, mMaxCyclesInCallWithChildren);
128 bool operator < (
const Aggregator &inRHS)
const
130 return mTotalCyclesInCallWithChildren > inRHS.mTotalCyclesInCallWithChildren;
138 uint64 mTotalCyclesInCallWithChildren = 0;
139 uint64 mMinCyclesInCallWithChildren = 0xffffffffffffffffUL;
140 uint64 mMaxCyclesInCallWithChildren = 0;
148 static void sAggregate(
int inDepth,
uint32 inColor,
ProfileSample *&ioSample,
const ProfileSample *inEnd, Aggregators &ioAggregators, KeyToAggregator &ioKeyToAggregator);
151 void UpdateReferenceTime();
154 uint64 GetProcessorTicksPerSecond()
const;
158 void DumpChart(
const char *inTag,
const Threads &inThreads,
const KeyToAggregator &inKeyToAggregators,
const Aggregators &inAggregators);
162 std::chrono::high_resolution_clock::time_point mReferenceTime;
198#ifdef JPH_SHARED_LIBRARY
222 static bool sOutOfSamplesReported;
233JPH_SUPPRESS_WARNING_PUSH
237#define JPH_PROFILE_START(name) do { Profiler::sInstance = new Profiler; JPH_PROFILE_THREAD_START(name); } while (false)
240#define JPH_PROFILE_END() do { JPH_PROFILE_THREAD_END(); delete Profiler::sInstance; Profiler::sInstance = nullptr; } while (false)
243#define JPH_PROFILE_THREAD_START(name) do { if (Profiler::sInstance) ProfileThread::sSetInstance(new ProfileThread(name)); } while (false)
246#define JPH_PROFILE_THREAD_END() do { delete ProfileThread::sGetInstance(); ProfileThread::sSetInstance(nullptr); } while (false)
249#define JPH_PROFILE_TAG2(line) profile##line
250#define JPH_PROFILE_TAG(line) JPH_PROFILE_TAG2(line)
251#define JPH_PROFILE(...) ProfileMeasurement JPH_PROFILE_TAG(__LINE__)(__VA_ARGS__)
254#define JPH_PROFILE_FUNCTION() JPH_PROFILE(JPH_FUNCTION_NAME)
257#define JPH_PROFILE_NEXTFRAME() Profiler::sInstance->NextFrame()
260#define JPH_PROFILE_DUMP(...) Profiler::sInstance->Dump(__VA_ARGS__)
262JPH_SUPPRESS_WARNING_POP
270JPH_SUPPRESS_WARNING_PUSH
273#define JPH_PROFILE_START(name)
274#define JPH_PROFILE_END()
275#define JPH_PROFILE_THREAD_START(name)
276#define JPH_PROFILE_THREAD_END()
277#define JPH_PROFILE(...)
278#define JPH_PROFILE_FUNCTION()
279#define JPH_PROFILE_NEXTFRAME()
280#define JPH_PROFILE_DUMP(...)
282JPH_SUPPRESS_WARNING_POP
std::uint8_t uint8
Definition: Core.h:440
#define JPH_EXPORT
Definition: Core.h:227
#define JPH_SUPPRESS_WARNINGS_STD_BEGIN
Definition: Core.h:372
#define JPH_SUPPRESS_WARNINGS_STD_END
Definition: Core.h:384
std::uint64_t uint64
Definition: Core.h:443
unsigned int uint
Definition: Core.h:439
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_CLANG_SUPPRESS_WARNING(w)
Definition: Core.h:254
std::uint32_t uint32
Definition: Core.h:442
#define JPH_EXPORT_GCC_BUG_WORKAROUND
Definition: Core.h:231
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:29
std::basic_string< char, std::char_traits< char >, STLAllocator< char > > String
Definition: STLAllocator.h:82
std::vector< T, STLAllocator< T > > Array
Definition: STLAllocator.h:81
std::unordered_map< Key, T, Hash, KeyEqual, STLAllocator< pair< const Key, T > > > UnorderedMap
Definition: UnorderedMap.h:13
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition: NonCopyable.h:11
Create this class on the stack to start sampling timing information of a particular scope.
Definition: Profiler.h:212
Definition: Profiler.h:170
uint32 mColor
Color to use for this sample.
Definition: Profiler.h:175
uint64 mEndCycle
Cycle counter at end of measurement.
Definition: Profiler.h:179
JPH_OVERRIDE_NEW_DELETE const char * mName
User defined name of this item.
Definition: Profiler.h:174
uint8 mDepth
Calculated depth.
Definition: Profiler.h:176
uint64 mStartCycle
Cycle counter at start of measurement.
Definition: Profiler.h:178
Collects all samples of a single thread.
Definition: Profiler.h:184
ProfileSample mSamples[cMaxSamples]
Buffer of samples.
Definition: Profiler.h:195
uint mCurrentSample
Next position to write a sample to.
Definition: Profiler.h:196
~ProfileThread()
Definition: Profiler.inl:17
static ProfileThread * sGetInstance()
Definition: Profiler.h:203
String mThreadName
Name of the thread that we're collecting information for.
Definition: Profiler.h:194
static void sSetInstance(ProfileThread *inInstance)
Definition: Profiler.h:202
static const uint cMaxSamples
Definition: Profiler.h:192
Singleton class for managing profiling information.
Definition: Profiler.h:79
JPH_OVERRIDE_NEW_DELETE Profiler()
Constructor.
Definition: Profiler.h:84
static Profiler * sInstance
Singleton instance.
Definition: Profiler.h:100