Navigation
API > API/Runtime > API/Runtime/Core
Centralizes the system to gather stats from a cook that need to be collected at the core/engine level. Essentially, add a delegate to the CookStatsCallbacks member. When a cook a complete that is configured to use stats (ENABLE_COOK_STATS), it will broadcast this delegate, which, when called, gives you a TFunction to call to report each of your stats.
For simplicity, FAutoRegisterCallback is provided to auto-register your callback on startup. Usage is like:
static void ReportCookStats(AddStatFuncRef AddStat) { AddStat("MySubsystem.Event1", CreateKeyValueArray("Attr1", "Value1", "Attr2", "Value2" ... ); AddStat("MySubsystem.Event2", CreateKeyValueArray("Attr1", "Value1", "Attr2", "Value2" ... ); }
FAutoRegisterCallback GMySubsystemCookRegistration(&ReportCookStats);
When a cook is complete, your callback will be called, and the stats will be either logged, sent to an analytics provider, logged to an external file, etc. You don't care how they are added, you just call AddStat for each stat you want to add.
| Name | FCookStatsManager |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/ProfilingDebugging/CookStats.h |
| Include Path | #include "ProfilingDebugging/CookStats.h" |
Syntax
class FCookStatsManager
Structs
| Name | Remarks |
|---|---|
| FAutoRegisterCallback | Helper struct to auto-register your STATIC FUNCTION with CookStatsCallbacks |
| TKeyValuePair | Copy of TKeyValuePair<> from Core, but with a default initializer for each member. |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| AddStatFuncRef | TFunctionRef< void(const FString &StatName, const TArray< StringKeyValue > &StatAttributes)> | When you register a callback for reporting your stats, you will be given a TFunctionRef to call to add stats. | ProfilingDebugging/CookStats.h |
| FGatherCookStatsDelegate | TMulticastDelegate_OneParam< void, AddStatFuncRef > | To register a callback for reporting stats, create an instance of this delegate type and add it to the delegate variable below. | ProfilingDebugging/CookStats.h |
| StringKeyValue | TKeyValuePair< FString, FString > | Every stat is essentially a name followed by an array of key/value "attributes" associated with the stat. | ProfilingDebugging/CookStats.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| CookStatsCallbacks | FGatherCookStatsDelegate | Use this to register a callback to gather cook stats for a translation unit. | ProfilingDebugging/CookStats.h |
Functions
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static TArray< FCookStatsManager::StringKeyValue > CreateKeyValueArray
(
ArgTypes&&... Args |
Helper to initialize an array of KeyValues on one line. | ProfilingDebugging/CookStats.h | |
static void ImplCreateKeyValueArray
(
TArray< FCookStatsManager::StringKeyValue >& Attrs, |
ProfilingDebugging/CookStats.h | ||
static void ImplCreateKeyValueArray
(
TArray< FCookStatsManager::StringKeyValue >& Attrs, |
ProfilingDebugging/CookStats.h | ||
static void ImplCreateKeyValueArray
(
TArray< FCookStatsManager::StringKeyValue >& Attrs, |
ProfilingDebugging/CookStats.h | ||
static void LogCookStats
(
AddStatFuncRef AddStat |
Called after the cook is finished to gather the stats. | ProfilingDebugging/CookStats.h | |
static TKeyValuePair< typename TDecay< KeyType >::Type, typename TDecay< ValueType >::Type > MakePair
(
KeyType&& InKey, |
Helper to construct a TKeyValuePair. | ProfilingDebugging/CookStats.h |