CauseHitchesHitchMS
CauseHitchesHitchMS
#Overview
name: CauseHitchesHitchMS
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Controls the size of the hitch caused by CauseHitches in ms.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of CauseHitchesHitchMS
is to control the size of artificial hitches in the game engine for testing and debugging purposes. It is part of the engine’s performance testing and debugging toolkit.
This setting variable is primarily used in the Engine module, specifically within the UnrealEngine.cpp file. It’s part of the core engine functionality rather than being tied to a specific subsystem or plugin.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 200 milliseconds, but can be changed at runtime through console commands or configuration files.
CauseHitchesHitchMS
interacts closely with another variable named CVarCauseHitchesMS
. They share the same value and purpose, with CVarCauseHitchesMS
being the actual CVar that stores the value.
Developers must be aware that using this variable will intentionally cause performance hitches in the game. It should only be used for testing and debugging purposes, never in a production build or during normal gameplay.
Best practices for using this variable include:
- Only enable it when specifically testing for hitch-related issues or performance profiling.
- Always disable it before creating production builds or when not actively debugging performance issues.
- Use in conjunction with profiling tools to better understand the impact of hitches on game performance.
Regarding the associated variable CVarCauseHitchesMS
:
The purpose of CVarCauseHitchesMS
is identical to CauseHitchesHitchMS
- it controls the size of artificial hitches for debugging purposes.
This variable is used in the Engine module, specifically in the UEngine::GetMaxTickRate
function. It’s part of the core engine’s timing and frame rate management system.
The value is set through the CVar system and can be modified at runtime. It’s used to determine the duration of the artificial sleep time that creates the hitch.
CVarCauseHitchesMS
directly interacts with the game loop timing. When enabled, it causes the engine to sleep for the specified duration once per second, creating a noticeable hitch.
Developers should be cautious when using this variable, as it directly impacts game performance. It should only be used in controlled testing environments.
Best practices for CVarCauseHitchesMS
include:
- Use it in conjunction with profiling tools to analyze how the game handles sudden performance drops.
- Experiment with different values to simulate various severity levels of performance issues.
- Always reset to 0 or disable completely when not actively testing hitch scenarios.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:11195
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarCauseHitchesMS(
TEXT("CauseHitchesHitchMS"), 200,
TEXT("Controls the size of the hitch caused by CauseHitches in ms."));
static TAutoConsoleVariable<int32> CVarUnsteadyFPS(
TEXT("t.UnsteadyFPS"),0,
TEXT("Causes FPS to bounce around randomly in the 8-32 range."));
#Associated Variable and Callsites
This variable is associated with another variable named CVarCauseHitchesMS
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:11194
Scope: file
Source code excerpt:
TEXT("Causes a 200ms hitch every second. Size of the hitch is controlled by CauseHitchesHitchMS"));
static TAutoConsoleVariable<int32> CVarCauseHitchesMS(
TEXT("CauseHitchesHitchMS"), 200,
TEXT("Controls the size of the hitch caused by CauseHitches in ms."));
static TAutoConsoleVariable<int32> CVarUnsteadyFPS(
TEXT("t.UnsteadyFPS"),0,
TEXT("Causes FPS to bounce around randomly in the 8-32 range."));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:11267
Scope (from outer to inner):
file
function float UEngine::GetMaxTickRate
Source code excerpt:
static float RunningHitchTimer = 0.f;
RunningHitchTimer += DeltaTime;
float SleepTime = float(CVarCauseHitchesMS.GetValueOnAnyThread()) / 1000.0f;
if (RunningHitchTimer > 1.f + SleepTime)
{
// hitch!
UE_LOG(LogEngine, Display, TEXT("Hitching by request!"));
FPlatformProcess::Sleep(SleepTime);
RunningHitchTimer = 0.f;