abtest.MinFramesPerTrial

abtest.MinFramesPerTrial

#Overview

name: abtest.MinFramesPerTrial

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of abtest.MinFramesPerTrial is to control the minimum number of frames to run a given command before switching during A/B testing in Unreal Engine 5.

This setting variable is primarily used in the profiling and debugging subsystem of Unreal Engine, specifically in the A/B testing module. It’s part of the Core module, as evidenced by its location in the ‘Core/Private/ProfilingDebugging’ directory.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 10 frames, but can be changed at runtime through console commands or configuration files.

The variable interacts directly with CVarABTestMinFramesPerTrial, which is the C++ representation of the console variable. This association allows the engine to access the value set by the user or configuration.

Developers should be aware that this variable affects the duration of each trial in A/B testing. A higher value will result in longer trials, which might provide more stable results but will also increase the overall testing time. Conversely, a lower value will speed up testing but might lead to less reliable results due to potential frame-to-frame variations.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of the test being conducted.
  2. Considering the performance characteristics of the features being tested.
  3. Balancing between test accuracy and total test duration.
  4. Documenting any non-default values used in specific tests for reproducibility.

Regarding the associated variable CVarABTestMinFramesPerTrial:

The purpose of CVarABTestMinFramesPerTrial is to provide a C++ interface to the abtest.MinFramesPerTrial console variable within the engine’s code.

This variable is used directly in the A/B testing implementation, specifically in the FABTest::Start function, where it’s used to set the MinFramesPerTrial member of the FABTest class.

The value of this variable is set by the console variable system and can be accessed in C++ code using the GetValueOnGameThread() method.

CVarABTestMinFramesPerTrial interacts closely with the console system and the FABTest class, serving as a bridge between user-configurable settings and the internal A/B testing logic.

Developers should be aware that changes to this variable will directly affect the behavior of the A/B testing system. It’s important to ensure that any code using this variable is prepared to handle potential runtime changes to its value.

Best practices for using CVarABTestMinFramesPerTrial include:

  1. Using GetValueOnGameThread() to access its current value, rather than caching it, to respect runtime changes.
  2. Considering thread safety when accessing this variable, as indicated by the use of GetValueOnGameThread().
  3. Using this variable in conjunction with other A/B testing variables for a comprehensive testing setup.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/ABTesting.cpp:36

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarABTestMinFramesPerTrial(
	TEXT("abtest.MinFramesPerTrial"),
	10,
	TEXT("The number of frames to run a given command before switching; this is randomized."));

static TAutoConsoleVariable<int32> CVarABTestNumResamples(
	TEXT("abtest.NumResamples"),
	256,

#Associated Variable and Callsites

This variable is associated with another variable named CVarABTestMinFramesPerTrial. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/ABTesting.cpp:35

Scope: file

Source code excerpt:

	TEXT("Number of frames to discard data after each command to cover threading."));

static TAutoConsoleVariable<int32> CVarABTestMinFramesPerTrial(
	TEXT("abtest.MinFramesPerTrial"),
	10,
	TEXT("The number of frames to run a given command before switching; this is randomized."));

static TAutoConsoleVariable<int32> CVarABTestNumResamples(
	TEXT("abtest.NumResamples"),

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/ABTesting.cpp:348

Scope (from outer to inner):

file
function     void FABTest::Start

Source code excerpt:

	ReportNum = CVarABTestReportNum.GetValueOnGameThread();
	CoolDown = CVarABTestCoolDown.GetValueOnGameThread();
	MinFramesPerTrial = CVarABTestMinFramesPerTrial.GetValueOnGameThread();
	NumResamples = CVarABTestNumResamples.GetValueOnGameThread();

	Samples.Empty(HistoryNum);
	ResampleAccumulators.Empty(NumResamples);
	ResampleAccumulators.AddZeroed(NumResamples);
	ResampleCount.Empty(NumResamples);