FCookStatsManager

Centralizes the system to gather stats from a cook that need to be collected at the core/engine level.

Windows
MacOS
Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/ProfilingDebugging/CookStats.h

Include

#include "ProfilingDebugging/CookStats.h"

Syntax

class FCookStatsManager

Remarks

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.

Functions

Name Description

Public function Static

TArray< FCoo...

 

CreateKeyValueArray

(
    ArgTypes&&... Args
)

Helper to initialize an array of KeyValues on one line.

Public function Static

void

 

LogCookStats

(
    AddStatFuncRef AddStat
)

Called after the cook is finished to gather the stats.

Public function Static

TKeyValuePai...

 

MakePair

(
    KeyType&& InKey,
    ValueType&& InValue
)

Helper to construct a TKeyValuePair.

Classes

Name

Description

Public struct

FAutoRegisterCallback

Helper struct to auto-register your STATIC FUNCTION with CookStatsCallbacks

Public struct

TKeyValuePair

Copy of TKeyValuePair<> from Core, but with a default initializer for each member.

Typedefs

Name

Description

AddStatFuncRef

When you register a callback for reporting your stats, you will be given a TFunctionRef to call to add stats.

FGatherCookStatsDelegate

To register a callback for reporting stats, create an instance of this delegate type and add it to the delegate variable below.

StringKeyValue

Every stat is essentially a name followed by an array of key/value "attributes" associated with the stat.

Constants

Name

Description

CookStatsCallbacks

Use this to register a callback to gather cook stats for a translation unit.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss