csv.statCounts

csv.statCounts

#Overview

name: csv.statCounts

This variable is created as a Console Variable (cvar).

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 that wraps the console variable, providing a programmatic interface to get and set its value.

Developers should be aware that:

  1. 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.
  2. This setting is checked at the beginning of each frame in the FCsvProfiler::BeginFrame() function.
  3. The value can be set via command line using the “-csvStatCounts” parameter.

Best practices when using this variable include:

  1. Only enable it when specifically needed for performance analysis or debugging.
  2. Be mindful of the performance overhead when enabled, especially in production builds.
  3. Use in conjunction with other CSV profiling tools for comprehensive performance analysis.

Regarding the associated variable CVarCsvStatCounts:

#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);