FHistogram

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

Choose your operating system:

Windows

macOS

Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/ProfilingDebugging/Histogram.h

Include

#include "ProfilingDebugging/Histogram.h"

Syntax

struct FHistogram

Remarks

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

Variables

Name Description

Protected variable

TArray< FBin >

 

Bins

Bins themselves, should be continous in terms of [MinValue; UpperBound) and sorted ascending by MinValue.

Protected variable

int64

 

CountOfAllMeasures

Protected variable

friend

 

FHistogramBuilder

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

Protected variable

double

 

MaximalMeasurement

Protected variable

double

 

MinimalMeasurement

Protected variable

double

 

SumOfAllMeasures

Quick stats for all bins

Functions

Name Description

Public function

void

 

AddMeasurement

(
    double Value
)

Adds an observed measurement.

Public function

void

 

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).

Public function Static

FString

 

DefaultConvertBinToLabel

(
    double MinValue,
    double UpperBound
)

Default stringifier for bins for use with DumpToJsonString.

Public function Const

FString

 

DumpToJsonString

(
    TFunctionRef< FString(double, doubl...
)

Returns a string in a Json format: [{"Bin":"BinName","Count":Count,"Sum":Sum},...].

Public function Const

FString

 

DumpToJsonString()

Same as DumpToJsonString but uses a DefaultConvertBinToLabel.

Public function Const

FString

 

DumpToJsonString2

(
    TFunctionRef< FString(double, doubl...
)

Returns a string in a Json format: [{"BinName":{"Count":Count,"Sum":Sum}},...].

Public function Const

FString

 

DumpToJsonString2()

Same as DumpToJsonString2 but uses a DefaultConvertBinToLabel.

Public function

void

 

DumpToLog

(
    const FString& HistogramName
)

Prints histogram contents to the log.

Public function Const

double

 

GetAverageOfAllMeasures()

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

Public function Const

double

 

GetBinLowerBound

(
    int IdxBin
)

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

Public function Const

int32

 

GetBinObservationsCount

(
    int IdxBin
)

Gets number of observations in the bin.

Public function Const

double

 

GetBinObservationsSum

(
    int IdxBin
)

Gets sum of observations in the bin.

Public function Const

double

 

GetBinUpperBound

(
    int IdxBin
)

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

Public function Const

double

 

GetMaxOfAllMeasures()

Returns the maximum of all measurements.

Public function Const

double

 

GetMinOfAllMeasures()

Returns the minimum of all measurements.

Public function Const

int32

 

GetNumBins()

Gets number of bins.

Public function Const

int64

 

GetNumMeasurements()

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

Public function Const

double

 

GetSumOfAllMeasures()

Returns the sum of all measurements

Public function

void

 

InitFromArray

(
    std::initializer_list< double > Thr...
)

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)

Public function

void

 

InitFromArray

(
    TArrayView< const double > Threshol...
)

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)

Public function

void

 

InitHitchTracking()

Inits histogram to mimic our existing hitch buckets

Public function

void

 

InitLinear

(
    double MinTime,
    double MaxTime,
    double BinSize
)

Inits histogram with linear, equally sized bins

Public function

void

 

Reset()

Resets measurements, without resetting the configured bins.

Operators

Name Description

Public function Const

FHistogram

 

operator-

(
    const FHistogram& Other
)

Public function Const

FHistogram

 

operator+

(
    const FHistogram& Other
)

Public function

FHistogram &

 

operator+=

(
    const FHistogram& Other
)

Classes

Name

Description

Protected struct

FBin

Bin