@univerjs/engine-render v0.5.4


Class: RollingAverage

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:222

RollingAverage

Utility to efficiently compute the rolling average and variance over a sliding window of samples

Constructors

new RollingAverage()

new RollingAverage(length): RollingAverage

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:246

constructor

Parameters

ParameterTypeDescription
lengthnumberThe number of samples required to saturate the sliding window

Returns

RollingAverage

Properties

PropertyModifierTypeDefault valueDescriptionDefined in
_m2protectednumber0-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:240
_posprotectednumber0-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:239
_sampleCountprotectednumber0for isStaturated max value of _sampleCount is length of _samplespackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:238
_samplesprotectednumber[][]-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:232
averageFrameTimepublicnumberDEFAULT_FRAME_TIMECurrent averagepackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:226
variancepublicnumber0Current variancepackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:231

Methods

_wrapPosition()

protected _wrapPosition(i): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:330

Wraps a value around the sample range boundaries

Parameters

ParameterTypeDescription
inumberPosition in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.

Returns

number

Wrapped position in sample range


addFrameTime()

addFrameTime(frameTime): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:286

Adds a sample to the sample set

Parameters

ParameterTypeDescription
frameTimenumberThe sample value

Returns

void


calcAverageFrameTime()

calcAverageFrameTime(): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:254

Calc average frameTime and variance.

Returns

void


history()

history(i): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:297

Returns previously added values or null if outside of history or outside the sliding window domain

Parameters

ParameterTypeDescription
inumberIndex in history. For example, pass 0 for the most recent value and 1 for the value before that

Returns

number

Value previously recorded with add() or null if outside of range


isSaturated()

isSaturated(): boolean

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:310

Returns true if enough samples have been taken to completely fill the sliding window

Returns

boolean

true if sample-set saturated


reset()

reset(): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:317

Resets the rolling average (equivalent to 0 samples taken so far)

Returns

void