UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FHistogram Struct Reference

#include <Histogram.h>

Classes

struct  FBin
 

Public Member Functions

CORE_API void InitLinear (double MinTime, double MaxTime, double BinSize)
 
CORE_API void InitHitchTracking ()
 
CORE_API void InitFromArray (TArrayView< const double > Thresholds)
 
UE_FORCEINLINE_HINT void InitFromArray (std::initializer_list< double > Thresholds)
 
CORE_API void Reset ()
 
void AddMeasurement (double Value)
 
CORE_API void AddMeasurement (double ValueForBinning, double MeasurementValue)
 
CORE_API void DumpToLog (const FString &HistogramName)
 
CORE_API FString DumpToJsonString (TFunctionRef< FString(double, double)> ConvertBinToLabel) const
 
CORE_API FString DumpToJsonString () const
 
CORE_API FString DumpToJsonString2 (TFunctionRef< FString(double, double)> ConvertBinToLabel) const
 
CORE_API FString DumpToJsonString2 () const
 
int32 GetNumBins () const
 
double GetBinLowerBound (int IdxBin) const
 
double GetBinUpperBound (int IdxBin) const
 
int32 GetBinObservationsCount (int IdxBin) const
 
double GetBinObservationsSum (int IdxBin) const
 
int64 GetNumMeasurements () const
 
double GetSumOfAllMeasures () const
 
double GetAverageOfAllMeasures () const
 
double GetMinOfAllMeasures () const
 
double GetMaxOfAllMeasures () const
 
FHistogram operator- (const FHistogram &Other) const
 
FHistogram operator+ (const FHistogram &Other) const
 
FHistogramoperator+= (const FHistogram &Other)
 

Static Public Member Functions

static CORE_API FString DefaultConvertBinToLabel (double MinValue, double UpperBound)
 

Protected Attributes

TArray< FBinBins
 
double SumOfAllMeasures
 
int64 CountOfAllMeasures
 
double MinimalMeasurement
 
double MaximalMeasurement
 
friend FHistogramBuilder
 

Detailed Description

Fairly generic histogram for values that have natural lower bound and possibly no upper bound, e.g., frame time

Member Function Documentation

◆ AddMeasurement() [1/2]

void FHistogram::AddMeasurement ( double  Value)
inline

Adds an observed measurement.

◆ AddMeasurement() [2/2]

void FHistogram::AddMeasurement ( double  ValueForBinning,
double  MeasurementValue 
)

Adds an observed measurement (with a different thresholding key than the measurement, e.g., when accumulating time spent in a chart keyed on framerate).

◆ DefaultConvertBinToLabel()

FString FHistogram::DefaultConvertBinToLabel ( double  MinValue,
double  UpperBound 
)
static

Default stringifier for bins for use with DumpToJsonString. Truncates to int and uses Plus as the suffix for the last bin. ie. [0.0, 3.75, 9.8] -> 0_3, 3_9, 9_Plus

◆ DumpToJsonString() [1/2]

FString FHistogram::DumpToJsonString ( ) const

Same as DumpToJsonString but uses a DefaultConvertBinToLabel.

◆ DumpToJsonString() [2/2]

FString FHistogram::DumpToJsonString ( TFunctionRef< FString(double, double)>  ConvertBinToLabel) const

Returns a string in a Json format: [{"Bin":"BinName","Count":Count,"Sum":Sum},...]. Bucket name is constructed by calling ConvertBinToLabel on the MinValue and UpperBound for each bin. Convert function is used to allow the bin range, which is stored as a double, to be printed prettily.

◆ DumpToJsonString2() [1/2]

FString FHistogram::DumpToJsonString2 ( ) const

Same as DumpToJsonString2 but uses a DefaultConvertBinToLabel.

◆ DumpToJsonString2() [2/2]

FString FHistogram::DumpToJsonString2 ( TFunctionRef< FString(double, double)>  ConvertBinToLabel) const

Returns a string in a Json format: [{"BinName":{"Count":Count,"Sum":Sum}},...]. Bucket name is constructed by calling ConvertBinToLabel on the MinValue and UpperBound for each bin. Convert function is used to allow the bin range, which is stored as a double, to be printed prettily.

◆ DumpToLog()

void FHistogram::DumpToLog ( const FString &  HistogramName)

Prints histogram contents to the log.

◆ GetAverageOfAllMeasures()

double FHistogram::GetAverageOfAllMeasures ( ) const
inline

Returns the average of all measurements (essentially a shortcut for Sum/Count).

◆ GetBinLowerBound()

double FHistogram::GetBinLowerBound ( int  IdxBin) const
inline

Gets lower bound of the bin, i.e. minimum value that goes into it.

◆ GetBinObservationsCount()

int32 FHistogram::GetBinObservationsCount ( int  IdxBin) const
inline

Gets number of observations in the bin.

◆ GetBinObservationsSum()

double FHistogram::GetBinObservationsSum ( int  IdxBin) const
inline

Gets sum of observations in the bin.

◆ GetBinUpperBound()

double FHistogram::GetBinUpperBound ( int  IdxBin) const
inline

Gets upper bound of the bin, i.e. first value that does not go into it.

◆ GetMaxOfAllMeasures()

double FHistogram::GetMaxOfAllMeasures ( ) const
inline

Returns the maximum of all measurements.

◆ GetMinOfAllMeasures()

double FHistogram::GetMinOfAllMeasures ( ) const
inline

Returns the minimum of all measurements.

◆ GetNumBins()

int32 FHistogram::GetNumBins ( ) const
inline

Gets number of bins.

◆ GetNumMeasurements()

int64 FHistogram::GetNumMeasurements ( ) const
inline

Returns the sum of all counts (the number of recorded measurements)

◆ GetSumOfAllMeasures()

double FHistogram::GetSumOfAllMeasures ( ) const
inline

Returns the sum of all measurements

◆ InitFromArray() [1/2]

UE_FORCEINLINE_HINT void FHistogram::InitFromArray ( std::initializer_list< double Thresholds)
inline

Inits histogram with the specified bin boundaries, with the final bucket extending to infinity (e.g., passing in 0,5 creates a [0..5) bucket and a [5..infinity) bucket)

◆ InitFromArray() [2/2]

void FHistogram::InitFromArray ( TArrayView< const double Thresholds)

Inits histogram with the specified bin boundaries, with the final bucket extending to infinity (e.g., passing in 0,5 creates a [0..5) bucket and a [5..infinity) bucket)

◆ InitHitchTracking()

void FHistogram::InitHitchTracking ( )

Inits histogram to mimic our existing hitch buckets

◆ InitLinear()

void FHistogram::InitLinear ( double  MinTime,
double  MaxTime,
double  BinSize 
)

Inits histogram with linear, equally sized bins

◆ operator+()

FHistogram FHistogram::operator+ ( const FHistogram Other) const
inline

◆ operator+=()

FHistogram & FHistogram::operator+= ( const FHistogram Other)
inline

◆ operator-()

FHistogram FHistogram::operator- ( const FHistogram Other) const
inline

◆ Reset()

void FHistogram::Reset ( )

Resets measurements, without resetting the configured bins.

Member Data Documentation

◆ Bins

TArray<FBin> FHistogram::Bins
protected

Bins themselves, should be continous in terms of [MinValue; UpperBound) and sorted ascending by MinValue. Last bin's UpperBound doesn't matter

◆ CountOfAllMeasures

int64 FHistogram::CountOfAllMeasures
protected

◆ FHistogramBuilder

friend FHistogram::FHistogramBuilder
protected

This is exposed as a clean way to build bins while enforcing the condition mentioned above

◆ MaximalMeasurement

double FHistogram::MaximalMeasurement
protected

◆ MinimalMeasurement

double FHistogram::MinimalMeasurement
protected

◆ SumOfAllMeasures

double FHistogram::SumOfAllMeasures
protected

Quick stats for all bins


The documentation for this struct was generated from the following files: