csv.statCounts
csv.statCounts
#Overview
name: csv.statCounts
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If 1, outputs count stats
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of csv.statCounts is to control the output of count statistics in the CSV profiler system of Unreal Engine 5. It is primarily used for profiling and debugging purposes within the engine’s performance monitoring capabilities.
This setting variable is used by the CSV Profiler subsystem, which is part of Unreal Engine’s core profiling and debugging tools. It’s located in the Core module of the engine, specifically within the ProfilingDebugging namespace.
The value of this variable is set through a console variable (CVar) system. It can be set programmatically, through the console, or via command-line arguments. The default value is 0, meaning count stats are not output by default.
The associated variable CVarCsvStatCounts interacts directly with csv.statCounts. It’s an instance of TAutoConsoleVariable
Developers should be aware that:
- Enabling this variable (setting it to 1) will cause the CSV Profiler to output count statistics, which may impact performance and increase the size of profiling data.
- This setting is checked at the beginning of each frame in the FCsvProfiler::BeginFrame() function.
- The value can be set via command line using the “-csvStatCounts” parameter.
Best practices when using this variable include:
- Only enable it when specifically needed for performance analysis or debugging.
- Be mindful of the performance overhead when enabled, especially in production builds.
- Use in conjunction with other CSV profiling tools for comprehensive performance analysis.
Regarding the associated variable CVarCsvStatCounts:
- It’s purpose is to provide a programmatic interface to the csv.statCounts console variable.
- It’s used within the Core module, specifically in the CSV Profiler system.
- Its value is set either through the console variable system or via the command line.
- It interacts directly with the GCsvStatCounts global variable, which is used to determine if count stats should be emitted.
- Developers should be aware that changes to CVarCsvStatCounts will immediately affect the behavior of the CSV Profiler.
- Best practices include using the GetValueOnGameThread() method to safely read its value, and avoiding frequent changes to its value during performance-critical operations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:130
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarCsvStatCounts(
TEXT("csv.statCounts"),
0,
TEXT("If 1, outputs count stats"),
ECVF_Default
);
TAutoConsoleVariable<int32> CVarCsvWriteBufferSize(
#Associated Variable and Callsites
This variable is associated with another variable named CVarCsvStatCounts
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:129
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarCsvStatCounts(
TEXT("csv.statCounts"),
0,
TEXT("If 1, outputs count stats"),
ECVF_Default
);
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:3065
Scope (from outer to inner):
file
function void FCsvProfiler::BeginFrame
Source code excerpt:
bNamedEventsWasEnabled = (GCycleStatsShouldEmitNamedEvents > 0);
GCsvStatCounts = !!CVarCsvStatCounts.GetValueOnGameThread();
// Initialize tls before setting the capturing flag to true.
FCsvProfilerThreadData::InitTls();
TRACE_CSV_PROFILER_BEGIN_CAPTURE(*Filename, RenderThreadId, RHIThreadId, GDefaultWaitStatName, GCsvStatCounts);
GCsvProfilerIsCapturing = true;
}
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:3863
Scope (from outer to inner):
file
function void FCsvProfiler::Init
Source code excerpt:
if (FParse::Param(FCommandLine::Get(), TEXT("csvStatCounts")))
{
CVarCsvStatCounts.AsVariable()->Set(1);
}
int32 NumCsvFrames = 0;
if (FParse::Value(FCommandLine::Get(), TEXT("csvCaptureFrames="), NumCsvFrames))
{
check(IsInGameThread());
BeginCapture(NumCsvFrames);