IntervalSeconds
IntervalSeconds
#Overview
name: IntervalSeconds
The value of this variable can be defined or overridden in .ini config files. 2
.ini config files referencing this setting variable.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of IntervalSeconds is to control the frequency of reporting network metrics in Unreal Engine’s network monitoring system. It sets the time interval between calls to the Report() function in network metric listeners.
This setting variable is primarily used by the Engine’s networking subsystem, specifically within the network metrics and monitoring module. It’s part of the UNetworkMetricsBaseListener class, which is likely used by various network-related plugins or modules that need to report network performance data.
The value of IntervalSeconds can be set in two ways:
- Programmatically, using the SetInterval() function of UNetworkMetricsBaseListener.
- Through configuration files (e.g., DefaultEngine.ini) by setting the IntervalSeconds property on listener sub-classes.
IntervalSeconds interacts with the Report() function of UNetworkMetricsBaseListener and its subclasses. It determines how often this function is called to report network metrics.
Developers should be aware that:
- IntervalSeconds should always be non-negative.
- Setting IntervalSeconds to 0 might lead to continuous reporting, which could impact performance.
- The actual reporting interval might not be exact due to the nature of game loop timing.
Best practices when using this variable include:
- Choose an appropriate interval that balances the need for frequent updates with performance considerations.
- Consider the nature of the metrics being reported and the game’s network requirements when setting the interval.
- Use configuration files for setting IntervalSeconds to allow for easy adjustments without code changes.
- When setting programmatically, use the SetInterval() function rather than modifying the variable directly to ensure proper validation.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEngine.ini:3506, section: [/Script/Engine.NetworkMetricsCSV_Replication]
- INI Section:
/Script/Engine.NetworkMetricsCSV_Replication
- Raw value:
0
- Is Array:
False
Location: <Workspace>/Engine/Config/BaseEngine.ini:3509, section: [/Script/Engine.NetworkMetricsPerfCounters]
- INI Section:
/Script/Engine.NetworkMetricsPerfCounters
- Raw value:
1
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Net/NetworkMetricsDatabase.cpp:196
Scope (from outer to inner):
file
function UNetworkMetricsBaseListener::UNetworkMetricsBaseListener
Source code excerpt:
UNetworkMetricsBaseListener::UNetworkMetricsBaseListener() :
UObject(),
IntervalSeconds(0)
{
}
UNetworkMetricsCSV::UNetworkMetricsCSV() :
CategoryIndex(-1)
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/Net/NetworkMetricsDatabase.h:123
Scope: file
Source code excerpt:
* All sub-classes of UNetworkMetricsBaseListener can set a time interval between calls to Report(). This is a useful method for limiting the rate
* at which metrics need to be recorded (e.g. you may only want to report metrics to an external analytics services every 60 seconds). This time interval
* can be set by calling UNetworkMetricsBaseListener::SetInterval() or in a configuration file by setting the IntervalSeconds property on the
* listener sub-class.
*
* This is an example configuration from an ini file (e.g. DefaultEngine.ini) that sets the interval between calling UNetworkMetricsMyListener::Report()
* to 1 second:
*
* [/Script/Engine.NetworkMetricsMyListener]
* IntervalSeconds=1
*/
UCLASS(abstract, Config=Engine)
class ENGINE_API UNetworkMetricsBaseListener : public UObject
{
GENERATED_BODY()
public:
UNetworkMetricsBaseListener();
virtual ~UNetworkMetricsBaseListener() = default;
/* Set the interval, in seconds, between calling Report(). */
void SetInterval(double Seconds)
{
if (ensureMsgf(Seconds >= 0, TEXT("SetInterval() called with a negative time interval.")))
{
IntervalSeconds = Seconds;
}
}
/* Get the interval, in seconds, between calling Report(). */
double GetInterval() const
{
return IntervalSeconds;
}
virtual void Report(const UE::Net::FNetworkMetricSnapshot& Snapshot) {};
private:
UPROPERTY(Config)
double IntervalSeconds;
};
/**
* A metrics listener that reports an array of metrics to CSV.
*
* The function SetCategory() is expected to be called before the listener is registered with
* FNetworkMetricsDatabase::Register(). This function will associate the instance of UNetworkMetricsCSV
* with a category of values in CSV.
*
* To use UNetworkMetricsCSV in a configuration file, a sub-class of UNetworkMetricsCSV must be
* created that calls SetCategory() from the constructor to provide the CSV category to use.
*
* UCLASS()
* class UNetworkMetricsCSV_ExampleCategory : public UNetworkMetricsCSV
* {
* GENERATED_BODY()
* public:
* virtual ~UNetworkMetricsCSV_ExampleCategory() = default;
*
* UNetworkMetricsCSV_ExampleCategory() : UNetworkMetricsCSV()
* {
* SetCategory("ExampleCategory");
* }
* };
#Loc: <Workspace>/Engine/Source/Runtime/TimeManagement/Private/TimeManagementTests.cpp:590
Scope (from outer to inner):
file
function bool FFrameTimeToSecondsConversionTest::RunTest
Source code excerpt:
// Get seconds representation according to frame-rate
const double FrameAsSeconds = FrameRate.AsSeconds(FrameIndex);
const double IntervalSeconds = static_cast<double>(FrameIndex) * Interval;
// Verify seconds value against interval * FrameIndex
ensureAlwaysMsgf(FMath::IsNearlyEqual(IntervalSeconds, FrameAsSeconds),
TEXT("Did not expect value %f ::AsSeconds for input %i (%f)."),
FrameAsSeconds, FrameIndex, IntervalSeconds
);
// Convert seconds values to FrameTime/FrameNumber values
const FFrameTime FrameTime = FrameRate.AsFrameTime(FrameAsSeconds);
const FFrameNumber FrameNumber = FrameRate.AsFrameNumber(FrameAsSeconds);